简体   繁体   English

角色反应机器人discord.python

[英]role react bot discord python

I'm trying to create a react role on a message that my bot would have sent, how can I do it?我正在尝试在我的机器人发送的消息上创建一个反应角色,我该怎么做? here is my code debut:这是我的代码首次亮相:

@bot.command(name = 'role_react_1')
async def role_react_1(ctx):
        del = await ctx.channel.history(limit=1).flatten()
    for each_messages in del:
        await each_messages.delete()
    message = await ctx.send("for have the role : evil : :smiling_imp: \nwhat role you want ?")
    await message.add_reaction("????")

    def checkEmoji(reaction):
        return message.id == reaction.message.id and str(reaction.emoji) == ":evil:"

    reaction = await bot.wait_for("reaction_add", check=checkEmoji)

    if reaction.emoji == ":evil:":
        role = discord.utils.get(ctx.guild.roles, name="evil")
        await ctx.author.add_roles(role)
        await ctx.send(f"the role {role} was assigned")

I've been told about 'on_raw_reaction_add' but I don't know how to use it.有人告诉我有关“on_raw_reaction_add”的信息,但我不知道如何使用它。 how to do it怎么做

if someone want a answer, it need a bot.event with reaction_add如果有人想要答案,它需要一个带有 reaction_add 的bot.event

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM