【发布时间】:2020-09-06 09:23:33
【问题描述】:
经过一些研究,我发现自己在这里写:
我希望当用户对✅ 对特定消息做出反应时,他必须给它一个角色并取消另一个角色。
但尝试它我不能在这里是我使用的代码:
spunta = "✅"
#Avvio del Bot
@client.event
async def on_ready():
channel = client.get_channel(749639084267536464)
global message
message = message.id(751836025697075270)
await message.add_reaction(msg, spunta)
@client.event
async def on_reaction_add(reaction, user):
if reaction.user == client.user:
return
if reaction.message == message and reaction.emoji == spunta:
role = get(user.guild.roles, id=691004248753832007)
await client.add_roles(user, role)
错误:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\PC GIUSEPPE\PycharmProjects\LMIIBot Development\venv\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:/Users/PC GIUSEPPE/PycharmProjects/LMIIBot Development/LMIIBot Development.py", line 253, in on_ready
message = message.id(751836025697075270)
NameError: name 'message' is not defined
【问题讨论】:
-
您正在尝试获取
message对象,但您尚未在代码中的任何位置定义它。
标签: discord.py