I am using discord.py to make a discord bot. I would like to generate a random number between 2 numbers mentioned by the user. So if the user types %rand 1 9
, I would like the bot to return with a random integer between 1 and 9, so say 4. Here is my code so far:
async def on_message(message):
x = str(1)
y = str(2)
if message.content.startswith('%rand ' + x + y):
NumberX = int(x)
NumberY = int(y)
msg = "Random Number Is: " + str(random.randint(NumberX,NumberY))
await client.send_message(message.channel, msg)
However, it doesn't work. I don't quite understand where I am going wrong. I couldn't find another solution anywhere else. I assume I need to force the bot to read the full message or something similar. Any help will be appreciated. Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire