fix: Replace io.redirect_stdout with contextlib.redirect_stdout for stdout redirection
This commit is contained in:
parent
b503db75ec
commit
63bdc18135
@ -3,6 +3,7 @@ from discord.ext import commands
|
||||
import io
|
||||
import textwrap
|
||||
import traceback
|
||||
import contextlib
|
||||
|
||||
class EvalCog(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
@ -41,10 +42,10 @@ class EvalCog(commands.Cog):
|
||||
exec(to_compile, env)
|
||||
except Exception as e:
|
||||
return await ctx.send(f'```py\n{e.__class__.__name__}: {e}\n```')
|
||||
|
||||
func = env['func']
|
||||
try:
|
||||
with io.redirect_stdout(stdout):
|
||||
with contextlib.redirect_stdout(stdout):
|
||||
ret = await func()
|
||||
ret = await func()
|
||||
except Exception as e:
|
||||
value = stdout.getvalue()
|
||||
|
Loading…
x
Reference in New Issue
Block a user