Найти - Пользователи
Полная версия: Error with message not difined (Discord, Python)
Начало » Центр помощи » Error with message not difined (Discord, Python)
1
Jexly
У меня есть такой код, написанный на python. Почему-то, при запуске выдает ошибку. Для меня это очень важный код, не могли ли Вы полностью исправить то что тут есть, и назвать причину из-за чего это? Вы мне очень сильно поможете, спасибо!

Сама ошибка:
Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\Name\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "welcome-bot.py", line 26, in on_member_join
await message.channel.send(member, newUserMessage)
NameError: name 'message' is not defined

Сам код:
import discord
import asyncio

client=discord.Client()

@client.event
async def on_ready():
print('logged in as')
print(client.user.name)
print(client.user.id)
print('-----')

newUserMessage = """ # customise this to the message you want to send new users
You
can
put
your
multiline
message
here!
"""

@client.event
async def on_member_join(member):
print("Recognised that a member called " + member.name + " joined")
await message.channel.send(member, newUserMessage)
print("Sent message to " + member.name)

# give member the steam role here
## to do this the bot must have 'Manage Roles' permission on server, and role to add must be lower than bot's top role
role = discord.utils.get(member.server.roles, name="name-of-your-role")
await message.channel.sends(member, role)
print("Added role '" + role.name + "' to " + member.name)

client.run('token')
doza_and
Jexly
Почему-то, при запуске выдает ошибку
Jexly
await message.channel.send(member, newUserMessage)
NameError: name ‘message’ is not defined
Потому что имя ‘message’ не определено. Что тут неясного? Определите его в соответствии с вашими целями и документацией пакета.
Jexly
не могли ли Вы полностью исправить то что тут есть
Исправить это невозможно потому что исправить можно систему у которой определено что она должна делать. А вы предлагаете судить о том что оно должно делать по неисправному коду.

Выглядит примерно так:
“Ребят я тут говорю Убрабым бабмбас. Меня не понимают!! Как это исправить?”
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB