Add await to eval

This commit is contained in:
Zeva Rose 2021-06-27 19:32:25 -06:00
parent 9afab6ae4b
commit 8fb9722d53

View file

@ -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}```")