Wrap eval in async def
This commit is contained in:
parent
8fb9722d53
commit
0589a8902c
1 changed files with 3 additions and 5 deletions
|
@ -241,14 +241,12 @@ class DevCog(commands.Cog):
|
||||||
@commands.command(name="eval")
|
@commands.command(name="eval")
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def _eval(self, ctx, *, code: str):
|
async def _eval(self, ctx, *, code: str):
|
||||||
|
code = f"async def fn():{code}"
|
||||||
try:
|
try:
|
||||||
output = eval(code, locals(), globals())
|
output = exec(code, globals(), locals())
|
||||||
except Exception:
|
except Exception:
|
||||||
output = traceback.format_exc()
|
output = traceback.format_exc()
|
||||||
if inspect.isawaitable(output):
|
await ctx.send(f"```{output}```")
|
||||||
await ctx.send(f"```{await output}```")
|
|
||||||
else:
|
|
||||||
await ctx.send(f"```{output}```")
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Add table
Reference in a new issue