diff options
21 files changed, 30 insertions, 23 deletions
@@ -6,7 +6,7 @@ from typing import List from aiohttp import AsyncResolver, ClientSession, TCPConnector from discord import Embed from discord.ext import commands -from discord.ext.commands import Bot +from discord.ext.commands import Bot, Cog from bot import constants @@ -63,6 +63,7 @@ class SeasonalBot(Bot): await devlog.send(embed=embed) + @Cog.listener() async def on_command_error(self, context, exception): # Don't punish the user for getting the arguments wrong if isinstance(exception, commands.UserInputError): diff --git a/bot/seasons/christmas/adventofcode.py b/bot/seasons/christmas/adventofcode.py index 3b199a4a..d360ae5e 100644 --- a/bot/seasons/christmas/adventofcode.py +++ b/bot/seasons/christmas/adventofcode.py @@ -108,7 +108,7 @@ async def day_countdown(bot: commands.Bot): await asyncio.sleep(120) -class AdventOfCode: +class AdventOfCode(commands.Cog): """ Advent of Code festivities! Ho Ho Ho! """ diff --git a/bot/seasons/evergreen/error_handler.py b/bot/seasons/evergreen/error_handler.py index 47e18a31..d764fe86 100644 --- a/bot/seasons/evergreen/error_handler.py +++ b/bot/seasons/evergreen/error_handler.py @@ -8,12 +8,13 @@ from discord.ext import commands log = logging.getLogger(__name__)
-class CommandErrorHandler:
+class CommandErrorHandler(commands.Cog):
"""A error handler for the PythonDiscord server!"""
def __init__(self, bot):
self.bot = bot
+ @commands.Cog.listener()
async def on_command_error(self, ctx, error):
"""Activates when a command opens an error"""
diff --git a/bot/seasons/evergreen/fun.py b/bot/seasons/evergreen/fun.py index 4da01dd1..0003714d 100644 --- a/bot/seasons/evergreen/fun.py +++ b/bot/seasons/evergreen/fun.py @@ -8,7 +8,7 @@ from bot.constants import Emojis log = logging.getLogger(__name__) -class Fun: +class Fun(commands.Cog): """ A collection of general commands for fun. """ diff --git a/bot/seasons/evergreen/uptime.py b/bot/seasons/evergreen/uptime.py index 1321da19..cce5ae76 100644 --- a/bot/seasons/evergreen/uptime.py +++ b/bot/seasons/evergreen/uptime.py @@ -9,7 +9,7 @@ from bot import start_time log = logging.getLogger(__name__) -class Uptime: +class Uptime(commands.Cog): """ A cog for posting the bots uptime. """ diff --git a/bot/seasons/halloween/candy_collection.py b/bot/seasons/halloween/candy_collection.py index 80f30a1b..d75e0d94 100644 --- a/bot/seasons/halloween/candy_collection.py +++ b/bot/seasons/halloween/candy_collection.py @@ -20,7 +20,7 @@ ADD_SKULL_REACTION_CHANCE = 50 # 2% ADD_SKULL_EXISTING_REACTION_CHANCE = 20 # 5% -class CandyCollection: +class CandyCollection(commands.Cog): def __init__(self, bot): self.bot = bot with open(json_location) as candy: @@ -31,6 +31,7 @@ class CandyCollection: userid = userinfo['userid'] self.get_candyinfo[userid] = userinfo + @commands.Cog.listener() async def on_message(self, message): """ Randomly adds candy or skull to certain messages @@ -54,6 +55,7 @@ class CandyCollection: self.msg_reacted.append(d) return await message.add_reaction('\N{CANDY}') + @commands.Cog.listener() async def on_reaction_add(self, reaction, user): """ Add/remove candies from a person if the reaction satisfies criteria diff --git a/bot/seasons/halloween/hacktoberstats.py b/bot/seasons/halloween/hacktoberstats.py index 41cf10ee..8ac448b8 100644 --- a/bot/seasons/halloween/hacktoberstats.py +++ b/bot/seasons/halloween/hacktoberstats.py @@ -13,7 +13,7 @@ from discord.ext import commands log = logging.getLogger(__name__) -class HacktoberStats: +class HacktoberStats(commands.Cog): def __init__(self, bot): self.bot = bot self.link_json = Path("bot", "resources", "github_links.json") diff --git a/bot/seasons/halloween/halloween_facts.py b/bot/seasons/halloween/halloween_facts.py index 098ee432..64f00ab3 100644 --- a/bot/seasons/halloween/halloween_facts.py +++ b/bot/seasons/halloween/halloween_facts.py @@ -25,7 +25,7 @@ PUMPKIN_ORANGE = discord.Color(0xFF7518) INTERVAL = timedelta(hours=6).total_seconds() -class HalloweenFacts: +class HalloweenFacts(commands.Cog): def __init__(self, bot): self.bot = bot @@ -35,6 +35,7 @@ class HalloweenFacts: self.facts = list(enumerate(self.halloween_facts)) random.shuffle(self.facts) + @commands.Cog.listener() async def on_ready(self): self.channel = self.bot.get_channel(Hacktoberfest.channel_id) self.bot.loop.create_task(self._fact_publisher_task()) diff --git a/bot/seasons/halloween/halloweenify.py b/bot/seasons/halloween/halloweenify.py index cda07472..9e1bae59 100644 --- a/bot/seasons/halloween/halloweenify.py +++ b/bot/seasons/halloween/halloweenify.py @@ -10,7 +10,7 @@ from discord.ext.commands.cooldowns import BucketType log = logging.getLogger(__name__) -class Halloweenify: +class Halloweenify(commands.Cog): """ A cog to change a invokers nickname to a spooky one! """ diff --git a/bot/seasons/halloween/monstersurvey.py b/bot/seasons/halloween/monstersurvey.py index 08873f24..aa5d97d2 100644 --- a/bot/seasons/halloween/monstersurvey.py +++ b/bot/seasons/halloween/monstersurvey.py @@ -4,7 +4,7 @@ import os from discord import Embed from discord.ext import commands -from discord.ext.commands import Bot, Context +from discord.ext.commands import Bot, Cog, Context log = logging.getLogger(__name__) @@ -14,7 +14,7 @@ EMOJIS = { } -class MonsterSurvey: +class MonsterSurvey(Cog): """ Vote for your favorite monster! This command allows users to vote for their favorite listed monster. diff --git a/bot/seasons/halloween/scarymovie.py b/bot/seasons/halloween/scarymovie.py index b280781e..c9a62edf 100644 --- a/bot/seasons/halloween/scarymovie.py +++ b/bot/seasons/halloween/scarymovie.py @@ -13,7 +13,7 @@ TMDB_API_KEY = environ.get('TMDB_API_KEY') TMDB_TOKEN = environ.get('TMDB_TOKEN') -class ScaryMovie: +class ScaryMovie(commands.Cog): """ Selects a random scary movie and embeds info into discord chat """ diff --git a/bot/seasons/halloween/spookyavatar.py b/bot/seasons/halloween/spookyavatar.py index b37a03f9..a2ed3b85 100644 --- a/bot/seasons/halloween/spookyavatar.py +++ b/bot/seasons/halloween/spookyavatar.py @@ -12,7 +12,7 @@ from bot.utils.halloween import spookifications log = logging.getLogger(__name__) -class SpookyAvatar: +class SpookyAvatar(commands.Cog): """ A cog that spookifies an avatar. diff --git a/bot/seasons/halloween/spookygif.py b/bot/seasons/halloween/spookygif.py index 1233773b..f013f415 100644 --- a/bot/seasons/halloween/spookygif.py +++ b/bot/seasons/halloween/spookygif.py @@ -9,7 +9,7 @@ from bot.constants import Tokens log = logging.getLogger(__name__) -class SpookyGif: +class SpookyGif(commands.Cog): """ A cog to fetch a random spooky gif from the web! """ diff --git a/bot/seasons/halloween/spookyreact.py b/bot/seasons/halloween/spookyreact.py index f63cd7e5..92afe798 100644 --- a/bot/seasons/halloween/spookyreact.py +++ b/bot/seasons/halloween/spookyreact.py @@ -2,6 +2,7 @@ import logging import re import discord +from discord.ext.commands import Cog log = logging.getLogger(__name__) @@ -16,7 +17,7 @@ SPOOKY_TRIGGERS = { } -class SpookyReact: +class SpookyReact(Cog): """ A cog that makes the bot react to message triggers. @@ -25,6 +26,7 @@ class SpookyReact: def __init__(self, bot): self.bot = bot + @Cog.listener() async def on_message(self, ctx: discord.Message): """ A command to send the seasonalbot github project diff --git a/bot/seasons/halloween/spookysound.py b/bot/seasons/halloween/spookysound.py index 4cab1239..1fbbfea6 100644 --- a/bot/seasons/halloween/spookysound.py +++ b/bot/seasons/halloween/spookysound.py @@ -10,7 +10,7 @@ from bot.constants import Hacktoberfest log = logging.getLogger(__name__) -class SpookySound: +class SpookySound(commands.Cog): """ A cog that plays a spooky sound in a voice channel on command. """ diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 0046ceb4..f589dbeb 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -15,7 +15,7 @@ log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -class BeMyValentine: +class BeMyValentine(commands.Cog): """ A cog that sends valentines to other users ! """ diff --git a/bot/seasons/valentines/lovecalculator.py b/bot/seasons/valentines/lovecalculator.py index 4df33b93..655430f5 100644 --- a/bot/seasons/valentines/lovecalculator.py +++ b/bot/seasons/valentines/lovecalculator.py @@ -9,7 +9,7 @@ from typing import Union import discord from discord import Member from discord.ext import commands -from discord.ext.commands import BadArgument, clean_content +from discord.ext.commands import BadArgument, Cog, clean_content from bot.constants import Roles @@ -20,7 +20,7 @@ with Path('bot', 'resources', 'valentines', 'love_matches.json').open() as file: LOVE_DATA = sorted((int(key), value) for key, value in LOVE_DATA.items()) -class LoveCalculator: +class LoveCalculator(Cog): """ A cog for calculating the love between two people """ diff --git a/bot/seasons/valentines/movie_generator.py b/bot/seasons/valentines/movie_generator.py index b52eba7f..ff0bb86b 100644 --- a/bot/seasons/valentines/movie_generator.py +++ b/bot/seasons/valentines/movie_generator.py @@ -11,7 +11,7 @@ TMDB_API_KEY = environ.get("TMDB_API_KEY") log = logging.getLogger(__name__) -class RomanceMovieFinder: +class RomanceMovieFinder(commands.Cog): """ A cog that returns a random romance movie suggestion to a user """ diff --git a/bot/seasons/valentines/savethedate.py b/bot/seasons/valentines/savethedate.py index b9484be9..f49d9ff4 100644 --- a/bot/seasons/valentines/savethedate.py +++ b/bot/seasons/valentines/savethedate.py @@ -13,7 +13,7 @@ log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -class SaveTheDate: +class SaveTheDate(commands.Cog): """ A cog that gives random suggestion, for a valentines date ! """ diff --git a/bot/seasons/valentines/valentine_zodiac.py b/bot/seasons/valentines/valentine_zodiac.py index 06c0237d..aa80a7e9 100644 --- a/bot/seasons/valentines/valentine_zodiac.py +++ b/bot/seasons/valentines/valentine_zodiac.py @@ -14,7 +14,7 @@ LETTER_EMOJI = ':love_letter:' HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -class ValentineZodiac: +class ValentineZodiac(commands.Cog): """ A cog that returns a counter compatible zodiac sign to the given user's zodiac sign. """ diff --git a/bot/seasons/valentines/whoisvalentine.py b/bot/seasons/valentines/whoisvalentine.py index 2fe07aba..ade4f131 100644 --- a/bot/seasons/valentines/whoisvalentine.py +++ b/bot/seasons/valentines/whoisvalentine.py @@ -14,7 +14,7 @@ with open(Path("bot", "resources", "valentines", "valentine_facts.json"), "r") a FACTS = json.load(file) -class ValentineFacts: +class ValentineFacts(commands.Cog): def __init__(self, bot): self.bot = bot |