From 875cf085b441623b9cf94e80adab341babfb0f3c Mon Sep 17 00:00:00 2001 From: "Dylan J." Date: Sun, 21 Sep 2025 17:53:04 -0400 Subject: [PATCH 1/2] Add restart bot command Restarts the bot from in discord! --- bot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bot.py b/bot.py index b052404..7d38436 100644 --- a/bot.py +++ b/bot.py @@ -134,6 +134,22 @@ def predicate(interaction: discord.Interaction): raise discord.app_commands.BotMissingPermissions(missing_permissions=missing_permissions) return discord.app_commands.checks.check(predicate) +@bot.tree.command( + name='restart', + description="Restarts the whole bot, bot maintainer use only!" +) +@discord.app_commands.checks.cooldown(rate=1, per=5) +@bot_has_channel_permissions(permissions=discord.Permissions(send_messages=True)) +async def retart(interaction: discord.Interaction): + if (await bot.is_owner(interaction.user)): + await interaction.response.send_message(f"Restarting Bot! You better be freaking sure about this!") + logger.info("Daddy Initiated Bot Restart....") + await restart_bot() + else: + logger.info("Pleb tried to restart me....") + await interaction.response.send_message(f"Awww look at you, how cute") + + @bot.tree.command( name='play', description="Begin playback of a shoutcast/icecast stream" From 3cc61b821858b708ffef08b5a38b240e7fe75ebd Mon Sep 17 00:00:00 2001 From: "Dylan J." Date: Mon, 29 Sep 2025 00:19:50 -0400 Subject: [PATCH 2/2] Branch fixed very nice --- bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot.py b/bot.py index b8a2f60..bc15b43 100644 --- a/bot.py +++ b/bot.py @@ -5,6 +5,7 @@ from discord.ext import commands, tasks import asyncio import os, datetime +import sys import logging, logging.handlers import urllib import validators @@ -642,6 +643,10 @@ async def on_command_error(interaction: discord.Interaction, error): def is_valid_url(url): return validators.url(url) +def restart_bot(): + logger.warning("Red Button Pushed!") + os.execv(sys.executable, ['python'] + sys.argv) + # Find information about the playing station & send that as an embed to the original text channel async def send_song_info(guild_id: int): url = get_state(guild_id, 'current_stream_url')