I'm currently new to coding, And I'm planning to make a utility bot. So basically, what I am trying to do here is getting the second argument for my on_message event. But how can I do that?
I'm making an auto math module for my bot, without using the prefix. For example: solve 5*5 and the bot was supposed to automatically answer it by reading the second argument.
My Code:
@client.event
async def on_message(message):
if message.content.startswith('solve'):
expression = # Where it supposed to read the arguments
await math(message, expression) # math function
discord.ext.commandsfor nicer command handling like this. Also please please please please do not useeval/exec/anything of that sort when evaluating math (what if I didsolve await ctx.send(client.http.token)?)... to be on the safe side useast.literal_evaleval(expression)for my math command. But I also usedtry/exceptwhich forbids some codes running. I tried it out myself, But thanks for that recommendation. I would use that''.__class__.__bases__[0]gives youobjecteven if you try to disallow that.ast.literal_evalbut i ran into some problem:malformed node or string on line 1: <ast.BinOp object at 0x760ceb4310>. I would ask this as question.