fix: Replace io.redirect_stdout with contextlib.redirect_stdout for stdout redirection

This commit is contained in:
Slipstream 2025-05-30 15:42:44 -06:00
parent b503db75ec
commit 63bdc18135
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

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