fix: Add context variable to dynamically compiled function in EvalCog

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

View File

@ -4,7 +4,6 @@ import io
import textwrap
import traceback
import contextlib
class EvalCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@ -36,7 +35,7 @@ class EvalCog(commands.Cog):
body = self.cleanup_code(body)
stdout = io.StringIO()
to_compile = f'async def func():\n{textwrap.indent(body, " ")}'
to_compile = f'async def func():\n _ctx = ctx\n{textwrap.indent(body, " ")}'
try:
exec(to_compile, env)