如何在 discord.py(rewrite) 中做出频道删除反应?

How to make a channel delete reaction in discord.py(rewrite)?

因此,我创建了一个命令 !vx new,它在特定类别中创建了一个具有作者和管理员设置的所有权限的新频道。现在我想创建一个删除票证的命令 - !vx close。这是我想出的代码,它可以工作,但问题是它可以从票证中的任何用户那里收到“是”。

@client.command(name='close', aliases=['delete'])
@commands.has_permissions(administrator=True)
async def close(ctx):
    await ctx.send("Do you want to delete this channel?")

    @commands.Cog.listener()
    async def on_reaction_add(self, reaction, user: discord.Member):

        def check(reaction, user):
            name_list = []
            for emoji in reaction.message.reactions:
                name_list.append(emoji.emoji)

            return '✅' in name_list and reaction.message.author.id == MyBotID and reaction.message.content == "Do you want to delete this channel?" and user.guild_permissions.administrator

        if check(reaction, user):
            await ctx.send("K!")
            await ctx.channel.delete()

我希望输入 !vx close 的用户对 cross/tick 标记作出反应,如果作者对勾作出反应,该标记将关闭工单,如果作者对叉做出反应,则不会关闭。

编辑 - 上面的代码也不起作用。

您可以从函数的上下文 (ctx) 中获取成员对象,并从 client.wait_for() 中获取消息。所以你可以让检查功能是:

return m.content.lower() == 'yes' and ctx.message.author == m.author

对于表情符号位,您可以在 on_reaction_add 事件中放置一个 if 语句来表示“如果我(机器人)发消息并且消息内容用于关闭和反应表情符号”同意并且用户有权限 'administrator' "

请求的表情符号代码: 它看起来像这样。

    @commands.Cog.listener()
    async def on_reaction_add(self, reaction, user : discord.Member):

        def check(reaction, user):
            name_list = []
            for emoji in reaction.message.reactions:
                name_list.append(emoji.emoji)

            return '✅' in name_list and reaction.message.author.id == yourBotsID and reaction.message.content == "Do you want to delete this channel?" and user.guild_permissions.administrator

        if check(reaction, user):
            await ctx.send("K!")
            await ctx.channel.delete()