D
D
Dream2021-05-20 20:24:45
Python
Dream, 2021-05-20 20:24:45

How to make a Discord command repeat?

Hello, how can I repeat a command as many times as the user specifies?

For example:

@bot.command
async def rand(ctx, number:int):
     random = random.randint(1, 100)
     await ctx.send(random)

number is the number to be repeated. That is, if number is 5, then the command should be repeated 5 times and give 5 random numbers. And how to make the default number 1 (if the user does not specify the number)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UberPool, 2021-05-20
@dreameddd

Something like that?

@bot.command()
async def rand(ctx, number:int):
     while number:
        test = random.randint(1, 100)
        await ctx.send(test)
        number -= 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question