@@ -45,9 +45,10 @@ def __init__(self, bot: core.Bot, endpoint_url: str) -> None:
45
45
self .eval_endpoint : str = endpoint_url
46
46
47
47
async def perform_eval (self , code : core .Codeblock ) -> str :
48
- async with self .bot .session .post (self .eval_endpoint , json = {"input" : code .content [ 1 ] }) as eval_response :
48
+ async with self .bot .session .post (self .eval_endpoint , json = {"input" : code .content }) as eval_response :
49
49
if eval_response .status != 200 :
50
- raise InvalidEval (eval_response .status , "There was an issue running this eval command." )
50
+ response_text = await eval_response .text ()
51
+ raise InvalidEval (eval_response .status , response_text )
51
52
52
53
eval_data = await eval_response .json ()
53
54
@@ -66,23 +67,17 @@ async def eval(
66
67
code_body: :class:`Codeblock`
67
68
This will attempt to convert your current passed parameter into proper Python code.
68
69
"""
69
- reaction = "\U00002705 "
70
70
71
71
async with ctx .typing ():
72
- try :
73
- output = await self .perform_eval (code )
74
- except InvalidEval :
75
- reaction = "\U0000274c "
76
-
77
- return await ctx .message .add_reaction (reaction )
72
+ output = await self .perform_eval (code )
78
73
79
74
if len (output ) > 1000 :
80
75
codeblock = await self .bot .mb_client .create_paste (content = output , filename = "eval.py" )
81
76
82
77
else :
83
78
codeblock = formatters .to_codeblock (output , escape_md = False )
84
79
85
- await ctx .message .add_reaction (reaction )
80
+ await ctx .message .add_reaction (" \U00002705 " )
86
81
await ctx .send (f"Hey { ctx .author .display_name } , here is your eval output:\n { codeblock } " )
87
82
88
83
@eval .error
@@ -95,7 +90,10 @@ async def eval_error_handler(self, ctx: core.Context, error: commands.CommandErr
95
90
return
96
91
97
92
elif isinstance (error , core .InvalidEval ):
98
- await ctx .send (f"Eval failed with status code: { error .error_code } ." )
93
+ await ctx .send (
94
+ f"Hey! Your eval job failed with status code: { error .error_code } . Error message is below:-\n { error } .\n Don't worry, the team here know!"
95
+ )
96
+ LOGGER .error ("Eval Cog raised an error during eval:\n %s" , str (error ))
99
97
100
98
101
99
async def setup (bot : core .Bot ) -> None :
0 commit comments