【发布时间】:2021-03-12 11:25:21
【问题描述】:
我正在创建一个反应角色频道,如果您使用表情符号做出反应,它会为您提供相应的角色。我在我的验证系统中使用了完全相同的代码,它运行良好。但是由于某种原因,当我使用相应的表情符号对消息做出反应时,我没有得到角色,没有显示回溯,并且我没有在控制台中看到“给某人一个角色”的消息。
代码:
async def roles(ctx):
embed=discord.Embed(title="Reaction Roles", description="React with the corresponding emoji to get the role", color=0xff0000, timestamp=datetime.now())
embed.set_author(name="Official Gnag Discord", icon_url="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/Exclamation_mark_red.png/50px-Exclamation_mark_red.png")
embed.add_field(name="⛓️", value="Role 1", inline=True)
embed.add_field(name="????", value="Role 2", inline=True)
embed.add_field(name="????", value="Role 3", inline=True)
embed.add_field(name="????️????", value="Role 4", inline=True)
embed.add_field(name="????", value="Role 5", inline=True)
embed.add_field(name="????", value="Role 6", inline=True)
embed.add_field(name="????", value="Role 7", inline=True)
embed.add_field(name="✔️", value="Role 8", inline=True)
embed.add_field(name="????", value="Role 9", inline=True)
embed.add_field(name="????", value="Role 10", inline=True)
embed.add_field(name="♂️", value="Role 11", inline=True)
embed.set_footer(text="Official Gnag Discord Bot Made By @Lukeee#6032")
msg = await ctx.send(embed=embed)
await msg.add_reaction('????')
await msg.add_reaction('✔️')
await msg.add_reaction('????')
await msg.add_reaction('????')
await msg.add_reaction('♂️')
await msg.add_reaction('⛓️')
await msg.add_reaction('????')
await msg.add_reaction('????')
await msg.add_reaction('????️????')
await msg.add_reaction('????')
await msg.add_reaction('????')
@bot.event
async def on_raw_reaction_add(payload):
ourMessageID = 819597141743763467
if ourMessageID == payload.message_id:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '????':
mrole = discord.utils.get(guild.roles, name='Role 7')
await member.add_roles(mrole)
print ('gave a role to someone')
【问题讨论】:
-
那有什么问题?
-
欢迎来到 StackOverflow。请阅读how-to-ask 并提出正确的问题
-
每当我添加一个反应,没有错误弹出或任何东西时,我还在控制台中将它编码为“给某人一个角色”,它没有这么说。
标签: python python-3.x discord.py