Add await to eval
This commit is contained in:
parent
9afab6ae4b
commit
8fb9722d53
1 changed files with 4 additions and 3 deletions
|
@ -238,15 +238,16 @@ class DevCog(commands.Cog):
|
||||||
output = subprocess.check_output(["cloc", "."]).decode("UTF-8")
|
output = subprocess.check_output(["cloc", "."]).decode("UTF-8")
|
||||||
await ctx.send(f"```\n{output}\n```")
|
await ctx.send(f"```\n{output}\n```")
|
||||||
|
|
||||||
@commands.is_owner()
|
|
||||||
@commands.command(name="eval")
|
@commands.command(name="eval")
|
||||||
|
@commands.is_owner()
|
||||||
async def _eval(self, ctx, *, code: str):
|
async def _eval(self, ctx, *, code: str):
|
||||||
try:
|
try:
|
||||||
output = eval(code, locals(), globals())
|
output = eval(code, locals(), globals())
|
||||||
except Exception:
|
except Exception:
|
||||||
output = traceback.format_exc()
|
output = traceback.format_exc()
|
||||||
if inspect.isawaitable(output):
|
if inspect.isawaitable(output):
|
||||||
output = await output
|
await ctx.send(f"```{await output}```")
|
||||||
|
else:
|
||||||
await ctx.send(f"```{output}```")
|
await ctx.send(f"```{output}```")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue