diff --git a/code/bot.py b/code/bot.py index fbe0223..c224797 100644 --- a/code/bot.py +++ b/code/bot.py @@ -79,6 +79,7 @@ bot = MyBot() bot.remove_command("help") bot.temp_command_count = {} # command_name: count bot.autoplay = [] # guild_id, guild_id, etc. +bot.youtube_broken = False @tasks.loop(minutes=45) diff --git a/code/cogs/owner/toggle.py b/code/cogs/owner/toggle.py index 7b93894..a276b01 100644 --- a/code/cogs/owner/toggle.py +++ b/code/cogs/owner/toggle.py @@ -1,8 +1,6 @@ from discord.ext import commands from typing import Literal -from utils.config import YOUTUBE_SUPPORT, YOUTUBE_BROKEN - class Toggle(commands.Cog): def __init__(self, bot): @@ -11,25 +9,18 @@ class Toggle(commands.Cog): @commands.command() @commands.dm_only() @commands.is_owner() - async def toggle( - self, ctx, action: Literal["disable", "enable", "broken"] - ): - """Toggle YouTube links""" - if action == "disable": - YOUTUBE_SUPPORT = False - YOUTUBE_BROKEN = False - return await ctx.send("YouTube has been disabled.") - - if action == "enable": - YOUTUBE_SUPPORT = True - YOUTUBE_BROKEN = False + async def toggle(self, ctx, action: Literal["on", "off"]): + """Toggle YouTube as broken or not""" + if action == "on": + self.bot.youtube_broken = False return await ctx.send("YouTube has been enabled.") - if action == "broken": - YOUTUBE_SUPPORT = False - YOUTUBE_BROKEN = True + if action == "off": + self.bot.youtube_broken = True return await ctx.send("YouTube has been marked as broken.") + await ctx.send("Invalid action. Please use 'on' or 'off'.") + async def setup(bot): await bot.add_cog(Toggle(bot)) diff --git a/code/cogs/play.py b/code/cogs/play.py index 5ff1eb6..1adee12 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, YOUTUBE_BROKEN, create_embed +from utils.config import YOUTUBE_SUPPORT, create_embed from utils.custom_sources import ( LoadError, CustomAudioTrack, @@ -45,7 +45,7 @@ class Play(commands.Cog): embed=embed, ephemeral=True ) - if YOUTUBE_BROKEN: + if self.bot.youtube_broken: embed = create_embed( title="YouTube Broken", description=( diff --git a/code/utils/config.py b/code/utils/config.py index c880bdc..19fed87 100644 --- a/code/utils/config.py +++ b/code/utils/config.py @@ -44,7 +44,6 @@ AI_MODEL = None LAVALINK_HOST = None LAVALINK_PORT = None LAVALINK_PASSWORD = None -YOUTUBE_BROKEN = False schema = { "type": "object", @@ -163,7 +162,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, YOUTUBE_BROKEN + 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 config = yaml.safe_load(file_contents) try: @@ -299,8 +298,6 @@ def validate_config(file_contents): LAVALINK_PORT = config["lavalink"]["port"] LAVALINK_PASSWORD = config["lavalink"]["password"] - YOUTUBE_BROKEN = False - """ Template for embeds