Add toggle command
Some checks are pending
Create and publish a Docker image / build-and-push-image (push) Waiting to run

This commit is contained in:
Parker M. 2025-03-25 23:03:45 -05:00
parent 06034d0b37
commit e578077df3
Signed by: parker
GPG Key ID: 505ED36FC12B5D5E
3 changed files with 56 additions and 2 deletions

35
code/cogs/owner/toggle.py Normal file
View File

@ -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))

View File

@ -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(

View File

@ -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