我如何制作一个机器人,如果你做出反应,它会给你一个python角色?

我如何制作一个机器人,如果你做出反应,它会给你一个python角色?,python,python-3.x,python-2.7,discord,discord.py,Python,Python 3.x,Python 2.7,Discord,Discord.py,因此,我一直在这样做: from discord.ext import commands from discord.utils import get client = commands.Bot(command_prefix='><') @client.event async def on_ready(): print("I am ready Winson or not Winson :D") @client.event async def on_

因此,我一直在这样做:

from discord.ext import commands
from discord.utils import get


client = commands.Bot(command_prefix='><')


@client.event
async def on_ready():
    print("I am ready Winson or not Winson :D")

@client.event
async def on_member_join(member):
    channel = client.get_channel(744440768667844698)
    message = await channel.send(f"Welcome to HaveNoFaith {member}, happy to be friends with you")

@client.command()
async def ping(ctx):
     await ctx.send(f"Your Ping is {round(client.latency *1000)}ms")

@client.command()
async def Help(ctx2):
    await ctx2.send("Hi, Im WelcomeBot v1.0...\n\nPrefix: ><\n\nCommands: ping\n          help")

来自discord.ext导入命令
从discord.utils导入获取

client=commands.Bot(command_prefix='>您可以生成一个名为
addrr
(addreaction role)的命令,如下所示-

@client.command()
@commands.guild_only()
@commands.has_permissions(administrator=True)
    async def addrr(self, ctx, channel: discord.TextChannel, message: discord.Message, emoji: discord.Emoji,
                    role: discord.Role):
        await ctx.send(f"Setting up the reaction roles in {channel.mention}.")
        await message.add_reaction(emoji)

        def check1(reaction, user):
            return user.id is not self.client.user.id and str(reaction.emoji) in [f"{emoji}"]

        while True:
            try:
                reaction, user = await self.client.wait_for("reaction_add", check=check1)
                if str(reaction.emoji) == f"{emoji}":
                    await user.add_roles(role)
                    await message.remove_reaction(reaction, user)
                else:
                    await message.remove_reaction(reaction, user)
            except:
                await message.delete()
                break
它将像这样工作-

@client.command()
@commands.guild_only()
@commands.has_permissions(administrator=True)
    async def addrr(self, ctx, channel: discord.TextChannel, message: discord.Message, emoji: discord.Emoji,
                    role: discord.Role):
        await ctx.send(f"Setting up the reaction roles in {channel.mention}.")
        await message.add_reaction(emoji)

        def check1(reaction, user):
            return user.id is not self.client.user.id and str(reaction.emoji) in [f"{emoji}"]

        while True:
            try:
                reaction, user = await self.client.wait_for("reaction_add", check=check1)
                if str(reaction.emoji) == f"{emoji}":
                    await user.add_roles(role)
                    await message.remove_reaction(reaction, user)
                else:
                    await message.remove_reaction(reaction, user)
            except:
                await message.delete()
                break

因此,您可以向发送的邮件添加一个反应,并用于等待对该邮件的反应。我建议您添加超时时间。如果您不想有此超时时间,只需发送这些邮件,将其保存到列表中,并在检查表情符号是否是您列表中的表情符号之一时查看想象。