mirror of
https://github.com/opus-tango/minecraft-server-discord-bot.git
synced 2026-03-20 03:55:20 +00:00
fix requirements and add clean up to botstop
This commit is contained in:
19
bot.py
19
bot.py
@@ -198,7 +198,7 @@ async def _stop_server_internal(ctx, servername, method):
|
|||||||
'''
|
'''
|
||||||
global active_server, active_server_pipe_task
|
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.")
|
await ctx.send("You don't have permission to run this command.")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -492,9 +492,22 @@ async def ping(ctx):
|
|||||||
@bot.command()
|
@bot.command()
|
||||||
async def botstop(ctx):
|
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()
|
await bot.close()
|
||||||
|
|
||||||
bot.run(TOKEN)
|
bot.run(TOKEN)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
python-dotenv
|
python-dotenv==1.1.1
|
||||||
discord.py
|
discord.py==2.6.2
|
||||||
Reference in New Issue
Block a user