Discord.PY,反应角色发生错误?

问题描述 投票:0回答:0

好吧,我正在尝试创建一个命令,用户在其中执行(前缀)请求角色不一致的角色ID。然后,它将请求嵌入发送到某个频道,某些角色可以在其中查看该频道,并且他们可以单击复选标记反应或“x”反应来接受或拒绝角色请求。

    @commands.command()
    async def requestrole(self, ctx, discordid, roleid):
        discordid = int(discordid)
        roleid = int(roleid)
        userid = ctx.author.id
        channel = self.bot.get_channel(FILLWITHCHANNELID)
        guild = ctx.guild
        user = ctx.author
        role = get(guild.roles, id=roleid)
        embed = discord.Embed(title="Role Request", description=f"{user} requested {role} for {userid}", color=0x00ff00)
        await channel.send(embed=embed)
        message = await embed.send(embed=embed)
        await message.add_reaction("✅")
        await message.add_reaction("❌")
        @self.bot.event
        async def on_reaction_add(reaction, user):
            if reaction.emoji == "✅":
                user = reaction.message.author
                guild = reaction.message.guild
                role = get(guild.roles, id=roleid)
                await user.add_roles(role)
                await channel.send(f"{user} has been given {role}")
            elif reaction.emoji == "❌":
                await reaction.message.send("Role request denied")

这是我现在收到的错误

忽略命令请求角色中的异常: 回溯(最近一次调用最后一次): 文件“C:\用户 ame\AppData\Roaming\Python\Python310\site-packages\discord x

python discord bots
© www.soinside.com 2019 - 2024. All rights reserved.