Wrap eval in async def

This commit is contained in:
Zeva Rose 2021-06-27 19:34:27 -06:00
parent 8fb9722d53
commit 0589a8902c

View file

@ -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):