Skip to content
Advertisement

discord.py How to make a roll dice command

Hello guys i’m coding a Discord bot in Python and i wanted to code a roll dice command. And i think im doing something wrong. Here is the code:

JavaScript

When i type the command and select number 4 my command does works but when i try another number, for an example 6, it doesn’t work. What am i doing wrong? Please help.

Advertisement

Answer

That’s because it checks for 4 first, then 6, and so on… Even after you send 4, it’ll check for 6, 8 and so on.. And when you send 6, it’ll check for 4 first, then 6 and so on.. Why don’t you try something like this instead:

JavaScript

Note: I recommend using await asyncio.sleep(1) instead of time.sleep(1). That way other commands will still be functional. Remember to import asyncio in this case.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement