aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo <[email protected]>2020-02-18 17:48:53 +0100
committerGravatar Matteo <[email protected]>2020-02-18 17:48:53 +0100
commit68cf5d8eb9721cb1d91ba004409b82b0a283782d (patch)
tree564f0845aafcf944f1b6c6f029a2506bdcf33b5b
parentWrite tests for bot/cogs/test_snekbox.py (diff)
Use pregenerated partials
This avoid recreating partials for each re-eval
-rw-r--r--bot/cogs/snekbox.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 3fc8d9937..d075c4fd5 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -203,6 +203,9 @@ class Snekbox(Cog):
log.info(f"Received code from {ctx.author} for evaluation:\n{code}")
+ _predicate_eval_message_edit = partial(predicate_eval_message_edit, ctx)
+ _predicate_emoji_reaction = partial(predicate_eval_emoji_reaction, ctx)
+
while True:
self.jobs[ctx.author.id] = datetime.datetime.now()
code = self.prepare_input(code)
@@ -234,13 +237,13 @@ class Snekbox(Cog):
try:
_, new_message = await self.bot.wait_for(
'message_edit',
- check=partial(predicate_eval_message_edit, ctx),
+ check=_predicate_eval_message_edit,
timeout=10
)
await ctx.message.add_reaction('🔁')
await self.bot.wait_for(
'reaction_add',
- check=partial(predicate_eval_emoji_reaction, ctx),
+ check=_predicate_emoji_reaction,
timeout=10
)