diff options
author | 2020-03-15 16:35:02 +0100 | |
---|---|---|
committer | 2020-03-15 16:36:22 +0100 | |
commit | a2852eab6ba73e8015aa703f6bb7a94253538b85 (patch) | |
tree | 3d557ac5ff4ec1d564bcbf3371a374544c4aee6c | |
parent | Deseasonify: add listener decorator for season locking (diff) |
Deseasonify: season-lock listeners where appropriate
We want to prevent listeners from performing season-specific behaviour
outside of specific months.
-rw-r--r-- | bot/seasons/halloween/candy_collection.py | 5 | ||||
-rw-r--r-- | bot/seasons/halloween/spookyreact.py | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/bot/seasons/halloween/candy_collection.py b/bot/seasons/halloween/candy_collection.py index 490609dd..3c65a745 100644 --- a/bot/seasons/halloween/candy_collection.py +++ b/bot/seasons/halloween/candy_collection.py @@ -8,7 +8,8 @@ from typing import List, Union import discord from discord.ext import commands -from bot.constants import Channels +from bot.constants import Channels, Month +from bot.decorators import in_month_listener log = logging.getLogger(__name__) @@ -35,6 +36,7 @@ class CandyCollection(commands.Cog): self.get_candyinfo[userid] = userinfo @commands.Cog.listener() + @in_month_listener(Month.october) async def on_message(self, message: discord.Message) -> None: """Randomly adds candy or skull reaction to non-bot messages in the Event channel.""" # make sure its a human message @@ -56,6 +58,7 @@ class CandyCollection(commands.Cog): return await message.add_reaction('\N{CANDY}') @commands.Cog.listener() + @in_month_listener(Month.october) async def on_reaction_add(self, reaction: discord.Reaction, user: discord.Member) -> None: """Add/remove candies from a person if the reaction satisfies criteria.""" message = reaction.message diff --git a/bot/seasons/halloween/spookyreact.py b/bot/seasons/halloween/spookyreact.py index 90b1254d..c6127298 100644 --- a/bot/seasons/halloween/spookyreact.py +++ b/bot/seasons/halloween/spookyreact.py @@ -4,6 +4,9 @@ import re import discord from discord.ext.commands import Bot, Cog +from bot.constants import Month +from bot.decorators import in_month_listener + log = logging.getLogger(__name__) SPOOKY_TRIGGERS = { @@ -24,6 +27,7 @@ class SpookyReact(Cog): self.bot = bot @Cog.listener() + @in_month_listener(Month.october) async def on_message(self, ctx: discord.Message) -> None: """ A command to send the seasonalbot github project. |