Files
Gwendolyn/gwendolyn/ext/events.py
2024-10-29 15:20:28 +01:00

21 lines
921 B
Python

from interactions import Extension, listen, Status, Activity, ActivityType
from interactions.api.events import Startup, Error
class EventExtension(Extension):
"""Listens to miscellaneous events."""
@listen(Startup)
async def startup(self, _):
"""Log and sets status when it logs in."""
name = self.bot.user.username
userid = str(self.bot.user.id)
logged_in_message = f"Logged in as {name}, {userid}"
self.bot.log(logged_in_message, level=25)
command_list = ",".join([str(i.name) for i in self.bot.application_commands])
self.bot.log(f"Commands: {command_list}")
activity = Activity("custom", ActivityType.CUSTOM, state="Type `/help` for commands")
await self.bot.change_presence(activity=activity, status=Status.ONLINE)
@listen(Error)
async def error(self, err: Error):
self.bot.log(f"Error at {err.source}", level=25)