From 7c5d841399cb058c518184deba8d3f8637d68852 Mon Sep 17 00:00:00 2001 From: Cromatin Date: Fri, 17 Jan 2025 17:19:21 +0100 Subject: [PATCH] Removed the maintenance check --- src/cogs/about.py | 1 - src/cogs/debug.py | 2 -- src/cogs/maintenance.py | 61 ----------------------------------------- src/cogs/post.py | 2 -- src/cogs/reload.py | 3 -- 5 files changed, 69 deletions(-) delete mode 100644 src/cogs/maintenance.py diff --git a/src/cogs/about.py b/src/cogs/about.py index c67035e..030dc6e 100644 --- a/src/cogs/about.py +++ b/src/cogs/about.py @@ -2,7 +2,6 @@ import discord from discord import app_commands from discord.ext import commands from cogs.base_cog import Base_Cog -from cogs.maintenance import Maintenance_Command import logging from utils.portal import Portal diff --git a/src/cogs/debug.py b/src/cogs/debug.py index dc44426..64f67d1 100644 --- a/src/cogs/debug.py +++ b/src/cogs/debug.py @@ -2,7 +2,6 @@ import discord from discord import app_commands from discord.ext import commands from cogs.base_cog import Base_Cog -from cogs.maintenance import Maintenance_Command import logging from utils.portal import Portal @@ -16,7 +15,6 @@ class Debug_Command(Base_Cog): super().__init__(logging.getLogger("cmds.debug")) @app_commands.command(name = "debug", description = "Provides debug informations about the bot, useful for troubleshooting") - @app_commands.check(Maintenance_Command.handle_check) @log_command_execution async def debug(self, ctx:discord.Interaction): portal:Portal = Portal.instance() diff --git a/src/cogs/maintenance.py b/src/cogs/maintenance.py deleted file mode 100644 index 019d3cc..0000000 --- a/src/cogs/maintenance.py +++ /dev/null @@ -1,61 +0,0 @@ -import discord -from discord.ext import commands -from discord import app_commands -from cogs.base_cog import Base_Cog - -import logging - - -class Maintenance_Command(Base_Cog): - def __init__(self, bot): - self.__bot = bot - self.__maintenance_mode_enabled = False - super().__init__(logging.getLogger("cmds.maintenance")) - - def enable_global_maintenance(self): - self.__maintenance_mode_enabled = True - - def disable_gloabal_maintenance(self): - self.__maintenance_mode_enabled = False - - @staticmethod - async def handle_check(ctx: discord.Integration): - """Check function called for every command""" - instance = ctx.client.get_cog("Maintenance_Command") - if instance and instance.__maintenance_mode_enabled: - await instance.startup(ctx) - return False - return True - - async def startup(self, ctx: discord.Interaction): - """Returns an message, explaining that the bot is still starting up""" - embed = discord.Embed( - title = ":construction: Bot is still starting up! :construction:", - description = "While the bot is starting, all commands are locked and unable to be executed", - color = 0xED4337) - await ctx.response.send_message(embed = embed) - - @commands.Cog.listener() - async def on_command_error(self, ctx, error): - if isinstance(error, app_commands.CheckFailure): - # Suppress the traceback and inform the user about maintenance mode - return # Already handled in the `startup` method - - cmds_group = app_commands.Group(name="maintenance", description="Put the bot into maintenance mode and control its alternative behaviour") - @cmds_group.command(name = "enable", description = "Enables the maintenance mode globally") - async def maintenance_enable(self, ctx: discord.Interaction): - if self.__maintenance_mode_enabled: - await ctx.response.send_message("Maintenance mode was allready enabled", ephemeral = True) - else: - await ctx.response.send_message("Maintenance mode is now enabled", ephemeral = True) - self.__maintenance_mode_enabled = True - - async def maintenance_disable(self, ctx: discord.Interaction): - if self.__maintenance_mode_enabled: - await ctx.response.send_message("Maintenance mode is now disabled", ephemeral = True) - else: - await ctx.response.send_message("Maintenance mode was allready disabled", ephemeral = True) - self.__maintenance_mode_enabled = False - -async def setup(bot:commands.Bot): - await bot.add_cog(Maintenance_Command(bot)) \ No newline at end of file diff --git a/src/cogs/post.py b/src/cogs/post.py index 6a127d2..8c324fd 100644 --- a/src/cogs/post.py +++ b/src/cogs/post.py @@ -2,7 +2,6 @@ import discord from discord import app_commands from discord.ext import commands from cogs.base_cog import Base_Cog -from cogs.maintenance import Maintenance_Command import logging from urllib.parse import urlparse @@ -20,7 +19,6 @@ class Post_Command(Base_Cog): super().__init__(logging.getLogger("cmds.post")) @app_commands.command(name = "post", description = "Post an embed in the Current Channel with a link to the content") - @app_commands.check(Maintenance_Command.handle_check) async def post(self, ctx:discord.Interaction, url:str, custom_note:str = None): domain_info = urlparse(url) portal = Portal.instance() diff --git a/src/cogs/reload.py b/src/cogs/reload.py index 9d660f2..60f9420 100644 --- a/src/cogs/reload.py +++ b/src/cogs/reload.py @@ -2,7 +2,6 @@ import discord from discord import app_commands from discord.ext import commands from cogs.base_cog import Base_Cog -from cogs.maintenance import Maintenance_Command import logging from datetime import datetime @@ -39,7 +38,6 @@ class Reload_Command(Base_Cog): return choices @app_commands.command(name = "reload_all", description = "Reloads all cogs") - @app_commands.check(Maintenance_Command.handle_check) async def reload_all(self, ctx: discord.Interaction): if self.__reload_running: await ctx.response.send_message("Reload is allready being executed", ephemeral = True) @@ -79,7 +77,6 @@ class Reload_Command(Base_Cog): @app_commands.command(name = "reload", description = "Reload specific cog") - @app_commands.check(Maintenance_Command.handle_check) @app_commands.autocomplete(cog_name = autocomplete_cog) async def reload(self, ctx: discord.Interaction, cog_name:str): if self.__reload_running: