From 2a45bc558c8eb3655bea8a4c3e6d2f01c038c8f1 Mon Sep 17 00:00:00 2001 From: Nayan <33187059+GShadow5@users.noreply.github.com> Date: Mon, 25 Aug 2025 22:20:54 -0400 Subject: [PATCH] fix requirements and add clean up to botstop --- bot.py | 19 ++++++++++++++++--- requirements.txt | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index 3bb9276..f564fbe 100644 --- a/bot.py +++ b/bot.py @@ -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) diff --git a/requirements.txt b/requirements.txt index 8e1be1a..8a70a62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -python-dotenv -discord.py \ No newline at end of file +python-dotenv==1.1.1 +discord.py==2.6.2 \ No newline at end of file