How do I make an eval command in

  discord,, python, python-3.x

I have a discord bot that is limited to me and a few friends. I want to make an eval command so I can show off to them since they know nothing about code, but also for me to use in general (I have a permissions system setup so it’s usage is limited to me, don’t worry).

I’ve done a lot of googling and the closest I’ve gotten is this:

async def eval(self, ctx, *, args):
    result = eval(args)
    await ctx.send(result)

This doesn’t work with multi-line code though. For example, I tried this code:

&eval a=2
print(str(a), str(b), str(c))

It returns this error: Invalid syntax and points to a=2 as the error. With other solutions like the ones from the creator’s github, it said that eval() takes 1 positional argument but 2 were given. I’m using the commands extension and the eval command will be in a cog. Thanks!

Source: Python Questions

One Reply to “How do I make an eval command in”

Leave a Reply to samuel buckley Cancel reply