feat(shutdown): Improve bot shutdown handling and logging

Added graceful shutdown support via signals in bot.py, improved shutdown command to use SIGTERM, and enhanced logging for shutdown events. Updated UDID command description for clarity.
This commit is contained in:
neoarz
2025-09-21 08:47:15 -04:00
parent 2e818d3453
commit f28ae00d7d
4 changed files with 65 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
import os
import signal
import discord
from discord.ext import commands
from discord.ext.commands import Context
@@ -28,6 +30,16 @@ class Shutdown(commands.Cog, name="shutdown"):
:param context: The hybrid command context.
"""
# Log command execution before shutdown starts
if context.guild is not None:
self.bot.logger.info(
f"Executed shutdown command in {context.guild.name} (ID: {context.guild.id}) by {context.author} (ID: {context.author.id})"
)
else:
self.bot.logger.info(
f"Executed shutdown command by {context.author} (ID: {context.author.id}) in DMs"
)
embed = discord.Embed(
title="Shutdown",
description="Shutting down. Bye! <a:PandaThanos:1417483671253811262>",
@@ -35,7 +47,7 @@ class Shutdown(commands.Cog, name="shutdown"):
).set_author(name="Owner", icon_url="https://yes.nighty.works/raw/zReOib.webp")
await self.send_embed(context, embed)
await self.bot.close()
os.kill(os.getpid(), signal.SIGTERM)
async def cog_command_error(self, context: Context, error) -> None:
if isinstance(error, commands.NotOwner):

View File

@@ -10,7 +10,7 @@ class Udid(commands.Cog, name="udid"):
self.bot = bot
@commands.hybrid_command(
name="udid", description="Information about SideStore UDID error"
name="udid", description="SideStore could not determine device UDID"
)
async def udid(self, context: Context) -> None:
embed = discord.Embed(