aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/halloween/spookyreact.py
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2021-04-19 17:04:11 -0400
committerGravatar ToxicKidz <[email protected]>2021-04-19 17:04:11 -0400
commitae64ddd3e7d731a44a1684c93d67ea6334b120d2 (patch)
tree8373f0171385d4065157ce0a4db5e686769ef272 /bot/exts/halloween/spookyreact.py
parentMerge pull request #673 from janine9vn/int-eval (diff)
Clean Up the Halloween Season
- Change commands.Bot type hints to bot.Bot - Remove the setting of Cog.bot if it isn't being used - Use Bot.http_session instead of creating new ones - Keep string quotes and Doc-Strings consistant - Remove redundant/outdated code Ignored spookyavatar.py as it is being moved in another PR.
Diffstat (limited to 'bot/exts/halloween/spookyreact.py')
-rw-r--r--bot/exts/halloween/spookyreact.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/bot/exts/halloween/spookyreact.py b/bot/exts/halloween/spookyreact.py
index b335df75..dabc3c1f 100644
--- a/bot/exts/halloween/spookyreact.py
+++ b/bot/exts/halloween/spookyreact.py
@@ -2,8 +2,9 @@ import logging
import re
import discord
-from discord.ext.commands import Bot, Cog
+from discord.ext.commands import Cog
+from bot.bot import Bot
from bot.constants import Month
from bot.utils.decorators import in_month
@@ -28,20 +29,20 @@ class SpookyReact(Cog):
@in_month(Month.OCTOBER)
@Cog.listener()
- async def on_message(self, ctx: discord.Message) -> None:
+ async def on_message(self, message: discord.Message) -> None:
"""Triggered when the bot sees a message in October."""
- for trigger in SPOOKY_TRIGGERS.keys():
- trigger_test = re.search(SPOOKY_TRIGGERS[trigger][0], ctx.content.lower())
+ for name, trigger in SPOOKY_TRIGGERS.items():
+ trigger_test = re.search(trigger[0], message.content.lower())
if trigger_test:
# Check message for bot replies and/or command invocations
# Short circuit if they're found, logging is handled in _short_circuit_check
- if await self._short_circuit_check(ctx):
+ if await self._short_circuit_check(message):
return
else:
- await ctx.add_reaction(SPOOKY_TRIGGERS[trigger][1])
- logging.info(f"Added '{trigger}' reaction to message ID: {ctx.id}")
+ await message.add_reaction(trigger[1])
+ log.info(f"Added {name!r} reaction to message ID: {message.id}")
- async def _short_circuit_check(self, ctx: discord.Message) -> bool:
+ async def _short_circuit_check(self, message: discord.Message) -> bool:
"""
Short-circuit helper check.
@@ -50,20 +51,20 @@ class SpookyReact(Cog):
* prefix is not None
"""
# Check for self reaction
- if ctx.author == self.bot.user:
- logging.debug(f"Ignoring reactions on self message. Message ID: {ctx.id}")
+ if message.author == self.bot.user:
+ log.debug(f"Ignoring reactions on self message. Message ID: {message.id}")
return True
# Check for command invocation
# Because on_message doesn't give a full Context object, generate one first
- tmp_ctx = await self.bot.get_context(ctx)
- if tmp_ctx.prefix:
- logging.debug(f"Ignoring reactions on command invocation. Message ID: {ctx.id}")
+ ctx = await self.bot.get_context(message)
+ if ctx.prefix:
+ log.debug(f"Ignoring reactions on command invocation. Message ID: {message.id}")
return True
return False
def setup(bot: Bot) -> None:
- """Spooky reaction Cog load."""
+ """Load the Spooky Reaction Cog."""
bot.add_cog(SpookyReact(bot))