reworking a bunch of stuff

This commit is contained in:
Nikolaj
2024-10-28 13:05:06 +01:00
parent f21cbba726
commit bc59bf9b05
142 changed files with 1385 additions and 845 deletions

View File

@ -0,0 +1,40 @@
"""Contains the EventCog, which runs code for specific bot events."""
from discord.ext import commands # Has the cog class
class EventCog(commands.Cog):
"""Handles bot events."""
def __init__(self, bot):
"""Initialize the bot."""
self.bot = bot
self.bot.on_error = self.on_error
@commands.Cog.listener()
async def on_ready(self):
"""Log and set bot status when bot logs in."""
await self.bot.event_handler.on_ready()
@commands.Cog.listener()
async def on_slash_command(self, ctx):
"""Log when a slash command is run."""
await self.bot.event_handler.on_slash_command(ctx)
@commands.Cog.listener()
async def on_slash_command_error(self, ctx, error):
"""Log when a slash error occurs."""
await self.bot.error_handler.on_slash_command_error(ctx, error)
async def on_error(self, method, *args, **kwargs): # pylint: disable=unused-argument
"""Log when an error occurs."""
await self.bot.error_handler.on_error(method)
@commands.Cog.listener()
async def on_component(self, ctx):
"""Handle when someone reacts to a message."""
await self.bot.event_handler.on_component(ctx)
def setup(bot):
"""Add the eventcog to the bot."""
bot.add_cog(EventCog(bot))