Files
Gwendolyn/gwendolyn/ext/misc.py
Nikolaj 2f4e606fbf
2024-10-30 15:31:46 +01:00

53 lines
1.9 KiB
Python

from interactions import Extension, slash_command, SlashContext, Status
from gwendolyn.utils import PARAMS as params
class MiscExtension(Extension):
"""Contains the miscellaneous commands."""
@slash_command(**params["misc"]["gen_name"])
async def gen_name(self, ctx: SlashContext):
await self.bot.other.generate_name(ctx)
@slash_command(**params["misc"]["hello"])
async def hello(self, ctx: SlashContext):
"""Greet the bot."""
await self.bot.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."""
latency = self.bot.latency
if latency > 100:
await ctx.send("Cannot measure latency :(")
else:
await ctx.send(f"Pong!\nLatency is {round(self.bot.latency * 1000)}ms")
@slash_command(**params["misc"]["roll"])
async def roll(self, ctx: SlashContext, dice: str = "1d20"):
await self.bot.other.roll_dice(ctx, dice)
@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}")