This commit is contained in:
2024-10-29 15:20:28 +01:00
parent eb2960aa10
commit e955ef4e28
34 changed files with 201 additions and 476 deletions

21
gwendolyn/ext/events.py Normal file
View File

@ -0,0 +1,21 @@
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)

View File

@ -1,9 +1,41 @@
from interactions import Extension, slash_command, SlashContext
from interactions import Extension, slash_command, SlashContext, Status
from gwendolyn.utils import PARAMS as params
class MiscExtension(Extension):
"""Contains the miscellaneous commands."""
@slash_command()
@slash_command(**params["misc"]["hello"])
async def hello(self, ctx: SlashContext):
"""Greet the bot."""
await ctx.send(f"Hello, I'm {self.bot.user.mention}!")
await self.other.hello_func(ctx)
@slash_command(**params["misc"]["help"])
async def help(self, ctx: SlashContext, command=""):
"""Get help for commands."""
await self.bot.other.help_func(ctx, command)
@slash_command(**params["misc"]["ping"])
async def ping(self, ctx: SlashContext):
"""Send the bot's latency."""
await ctx.send(f"Pong!\nLatency is {round(self.bot.latency * 1000)}ms")
@slash_command(**params["misc"]["thank"])
async def thank(self, ctx: SlashContext):
"""Thank the bot."""
await ctx.send("You're welcome :blush:")
@slash_command(**params["misc"]["stop"])
async def stop(self, ctx: SlashContext):
if f"{ctx.author.id}" in self.bot.admins:
await ctx.send("Goodnight...")
await self.bot.change_presence(status=Status.INVISIBLE)
# self.bot.database_funcs.wipe_games()
self.bot.log("Logging out", level=25)
await self.bot.stop()
else:
log_message = f"{ctx.author.display_name} tried to stop me!"
self.bot.log(log_message, str(ctx.channel_id))
await ctx.send(f"I don't think I will, {ctx.author.display_name}")