My code:
elif message.content.startswith(";random-number"):
channel = client.get_channel(1004728545911787740)
await channel.send("**Command received:** " + str(message.content) + "\n ```" + str(message) + "```")
try:
range = int(message.content.replace(";random-number ", "")
await message.channel.send("Random number: " + random.randint(0, int(range)))
except:
await message.channel.send(random.choice(["Use the command like this: ", "Here is how you can use the command: "]))
await message.channel.send("`;random-number [max number]`\nExample:\nUser - `;random-number 100`\nCorion - Random number: 67")
When I run my code I get this error:
File "main.py", line 150
await message.channel.send("Random number: " + random.randint(0, int(range)))
^
SyntaxError: invalid syntax
It seems there a syntax problem at this line:
I can't really understand where the syntax error is though. I also tried str-ing the random.randint(0,int(range) but it doesn't work either. Any help is appreciated!
Your syntax issue is the line above
range = int(message.content.replace(";random-number ", "")
You are missing the closing brace
range = int(message.content.replace(";random-number ", ""))