Skip to content

Commit 458251e

Browse files
fix broken cog (#30)
1 parent 94856d7 commit 458251e

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

config.template.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ webhook_avatar_url = "" # optional
2020
level = 20
2121

2222
[SNEKBOX] # optional
23-
url = 'http://snekbox:8060' # default url
23+
url = 'http://snekbox:8060/eval' # default url
2424

2525
[GITHUB] # optional
2626
bot_secret = ""

modules/eval.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ def __init__(self, bot: core.Bot, endpoint_url: str) -> None:
4545
self.eval_endpoint: str = endpoint_url
4646

4747
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:
4949
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)
5152

5253
eval_data = await eval_response.json()
5354

@@ -66,23 +67,17 @@ async def eval(
6667
code_body: :class:`Codeblock`
6768
This will attempt to convert your current passed parameter into proper Python code.
6869
"""
69-
reaction = "\U00002705"
7070

7171
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)
7873

7974
if len(output) > 1000:
8075
codeblock = await self.bot.mb_client.create_paste(content=output, filename="eval.py")
8176

8277
else:
8378
codeblock = formatters.to_codeblock(output, escape_md=False)
8479

85-
await ctx.message.add_reaction(reaction)
80+
await ctx.message.add_reaction("\U00002705")
8681
await ctx.send(f"Hey {ctx.author.display_name}, here is your eval output:\n{codeblock}")
8782

8883
@eval.error
@@ -95,7 +90,10 @@ async def eval_error_handler(self, ctx: core.Context, error: commands.CommandErr
9590
return
9691

9792
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}.\nDon't worry, the team here know!"
95+
)
96+
LOGGER.error("Eval Cog raised an error during eval:\n%s", str(error))
9997

10098

10199
async def setup(bot: core.Bot) -> None:

0 commit comments

Comments
 (0)