Files
Gwendolyn/cogs/EventCog.py
NikolajDanger aff29a8d91 🧹 Cleaning up cogs
2021-03-31 16:53:37 +02:00

35 lines
1.1 KiB
Python

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()
@commands.Cog.listener()
async def on_disconnect(self):
await self.bot.change_presence(status = discord.Status.offline)
# 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))