fix: Add context variable to dynamically compiled function in EvalCog
This commit is contained in:
parent
63bdc18135
commit
a89671fa42
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user