aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2025-03-25 23:03:45 -0500
committerParker <contact@pkrm.dev>2025-03-25 23:03:45 -0500
commite578077df3f9af70befa6fa69d4dfcedb5986ce1 (patch)
tree53dacb3ff61a955e127bad80798d7517bd397f35 /code
parent06034d0b373a9aed5033c2e670950f765e285c2a (diff)
Add toggle command
Diffstat (limited to 'code')
-rw-r--r--code/cogs/owner/toggle.py35
-rw-r--r--code/cogs/play.py18
-rw-r--r--code/utils/config.py5
3 files changed, 56 insertions, 2 deletions
diff --git a/code/cogs/owner/toggle.py b/code/cogs/owner/toggle.py
new file mode 100644
index 0000000..2ab6944
--- /dev/null
+++ b/code/cogs/owner/toggle.py
@@ -0,0 +1,35 @@
+from discord.ext import commands
+from typing import Literal
+
+import utils.config as config
+
+
+class Toggle(commands.Cog):
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.command()
+ @commands.dm_only()
+ @commands.is_owner()
+ async def toggle(
+ self, ctx, action: Literal["disable", "enable", "broken"]
+ ):
+ """Toggle YouTube links"""
+ if action == "disable":
+ config.YOUTUBE_SUPPORT = False
+ config.YOUTUBE_BROKEN = False
+ return await ctx.send("YouTube has been disabled.")
+
+ if action == "enable":
+ config.YOUTUBE_SUPPORT = True
+ config.YOUTUBE_BROKEN = False
+ return await ctx.send("YouTube has been enabled.")
+
+ if action == "broken":
+ config.YOUTUBE_SUPPORT = False
+ config.YOUTUBE_BROKEN = True
+ return await ctx.send("YouTube has been marked as broken.")
+
+
+async def setup(bot):
+ await bot.add_cog(Toggle(bot))
diff --git a/code/cogs/play.py b/code/cogs/play.py
index 76704ac..5ff1eb6 100644
--- a/code/cogs/play.py
+++ b/code/cogs/play.py
@@ -6,7 +6,7 @@ from lavalink import LoadType
import re
from cogs.music import Music, LavalinkVoiceClient
-from utils.config import YOUTUBE_SUPPORT, create_embed
+from utils.config import YOUTUBE_SUPPORT, YOUTUBE_BROKEN, create_embed
from utils.custom_sources import (
LoadError,
CustomAudioTrack,
@@ -45,6 +45,22 @@ class Play(commands.Cog):
embed=embed, ephemeral=True
)
+ if YOUTUBE_BROKEN:
+ embed = create_embed(
+ title="YouTube Broken",
+ description=(
+ "YouTube support is currently broken. This is a known"
+ " issue and is being actively worked on, please try"
+ " again later. Other sources should still be in"
+ " working order. Submit a bug report with "
+ " </bug:1224840889906499626> if issues persist. Sorry"
+ " for the inconvenience."
+ ),
+ )
+ return await interaction.response.send_message(
+ embed=embed, ephemeral=True
+ )
+
# Check for custom sources (Apple Music/Spotify)
if "music.apple.com" in query:
results, embed = await parse_custom_source(
diff --git a/code/utils/config.py b/code/utils/config.py
index 19fed87..c880bdc 100644
--- a/code/utils/config.py
+++ b/code/utils/config.py
@@ -44,6 +44,7 @@ AI_MODEL = None
LAVALINK_HOST = None
LAVALINK_PORT = None
LAVALINK_PASSWORD = None
+YOUTUBE_BROKEN = False
schema = {
"type": "object",
@@ -162,7 +163,7 @@ ai:
# Thouroughly validate all of the options in the config.yaml file
def validate_config(file_contents):
- global TOKEN, BOT_COLOR, BOT_INVITE_LINK, FEEDBACK_CHANNEL_ID, BUG_CHANNEL_ID, LOG_SONGS, YOUTUBE_SUPPORT, SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, GENIUS_CLIENT_ID, GENIUS_CLIENT_SECRET, AI_CLIENT, AI_MODEL, LAVALINK_HOST, LAVALINK_PORT, LAVALINK_PASSWORD
+ global TOKEN, BOT_COLOR, BOT_INVITE_LINK, FEEDBACK_CHANNEL_ID, BUG_CHANNEL_ID, LOG_SONGS, YOUTUBE_SUPPORT, SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, GENIUS_CLIENT_ID, GENIUS_CLIENT_SECRET, AI_CLIENT, AI_MODEL, LAVALINK_HOST, LAVALINK_PORT, LAVALINK_PASSWORD, YOUTUBE_BROKEN
config = yaml.safe_load(file_contents)
try:
@@ -298,6 +299,8 @@ def validate_config(file_contents):
LAVALINK_PORT = config["lavalink"]["port"]
LAVALINK_PASSWORD = config["lavalink"]["password"]
+ YOUTUBE_BROKEN = False
+
"""
Template for embeds