import discord from discord.ext import commands class EventCog(commands.Cog): def __init__(self, bot): self.bot = bot # Syncs commands, sets the game, and logs when the bot logs in @commands.Cog.listener() async def on_ready(self): await self.bot.eventHandler.on_ready() # Logs when user sends a command @commands.Cog.listener() async def on_slash_command(self, ctx): logMessage = f"{ctx.author.display_name} ran /{ctx.name}" self.bot.log(logMessage, str(ctx.channel_id), level = 25) # Logs if a command experiences an error @commands.Cog.listener() async def on_slash_command_error(self, ctx, error): await self.bot.errorHandler.on_slash_command_error(ctx, error) # Logs if an error occurs @commands.Cog.listener() async def on_error(self, method): await self.bot.errorHandler.on_error(method) def setup(bot): bot.add_cog(EventCog(bot))