41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
"""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))
|