我无法使此代码正常工作,发布响应消息是没有问题的。但是,给具有“测试版”角色的用户是行不通的。
Discord.py版本:0.16.12
@bot.command(pass_context=True)
async def test(ctx):
if ctx.message.author.server_permissions.administrator:
testEmbed = discord.Embed(color = discord.Color.red())
testEmbed.set_author(name='Test')
testEmbed.add_field(name='Test', value='Test')
msg = await bot.send_message(ctx.message.channel, embed=testEmbed)
await bot.add_reaction(msg, emoji='✅')
@bot.event
async def on_reaction_add(reaction, user):
Channel = bot.get_channel('714282896780951563')
if reaction.message.channel.id != Channel:
return
if reaction.emoji == "✅":
Role = discord.utils.get(user.server.roles, name="Beta")
await bot.add_roles(user, Role)
答案 0 :(得分:0)
reaction.message.channel.id != Channel
永远不会是True
,因为Channel
是discord.Channel
对象,而reaction.message.channel.id
是字符串。
相反,您应该直接将ID与预期ID进行比较:
if reaction.message.channel.id != '714282896780951563':