fix requirements and add clean up to botstop

This commit is contained in:
Nayan
2025-08-25 22:20:54 -04:00
parent d6605850ea
commit 2a45bc558c
2 changed files with 18 additions and 5 deletions

19
bot.py
View File

@@ -198,7 +198,7 @@ async def _stop_server_internal(ctx, servername, method):
'''
global active_server, active_server_pipe_task
if not ctx.author.guild_permissions.administrator:
if not ctx.author.guild_permissions.administrator and method == "forcestop":
await ctx.send("You don't have permission to run this command.")
return
@@ -492,9 +492,22 @@ async def ping(ctx):
@bot.command()
async def botstop(ctx):
'''
Stop the bot
Stop the bot and clean up
'''
global active_server, active_server_pipe_task
if active_server_pipe_task:
active_server_pipe_task.cancel()
try:
await active_server_pipe_task # Await to ensure it cleans up
except asyncio.CancelledError:
pass # Expected
active_server_pipe_task = None
if active_server:
await _delete_named_pipe(active_server) # Delete the pipe file
await bot.close()
bot.run(TOKEN)