Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -128,6 +129,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"
Expand Down Expand Up @@ -626,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')
Expand Down