Removed the maintenance check
This commit is contained in:
@@ -2,7 +2,6 @@ import discord
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from cogs.base_cog import Base_Cog
|
from cogs.base_cog import Base_Cog
|
||||||
from cogs.maintenance import Maintenance_Command
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from utils.portal import Portal
|
from utils.portal import Portal
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import discord
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from cogs.base_cog import Base_Cog
|
from cogs.base_cog import Base_Cog
|
||||||
from cogs.maintenance import Maintenance_Command
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from utils.portal import Portal
|
from utils.portal import Portal
|
||||||
@@ -16,7 +15,6 @@ class Debug_Command(Base_Cog):
|
|||||||
super().__init__(logging.getLogger("cmds.debug"))
|
super().__init__(logging.getLogger("cmds.debug"))
|
||||||
|
|
||||||
@app_commands.command(name = "debug", description = "Provides debug informations about the bot, useful for troubleshooting")
|
@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
|
@log_command_execution
|
||||||
async def debug(self, ctx:discord.Interaction):
|
async def debug(self, ctx:discord.Interaction):
|
||||||
portal:Portal = Portal.instance()
|
portal:Portal = Portal.instance()
|
||||||
|
|||||||
@@ -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))
|
|
||||||
@@ -2,7 +2,6 @@ import discord
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from cogs.base_cog import Base_Cog
|
from cogs.base_cog import Base_Cog
|
||||||
from cogs.maintenance import Maintenance_Command
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
@@ -20,7 +19,6 @@ class Post_Command(Base_Cog):
|
|||||||
super().__init__(logging.getLogger("cmds.post"))
|
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.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):
|
async def post(self, ctx:discord.Interaction, url:str, custom_note:str = None):
|
||||||
domain_info = urlparse(url)
|
domain_info = urlparse(url)
|
||||||
portal = Portal.instance()
|
portal = Portal.instance()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import discord
|
|||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from cogs.base_cog import Base_Cog
|
from cogs.base_cog import Base_Cog
|
||||||
from cogs.maintenance import Maintenance_Command
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -39,7 +38,6 @@ class Reload_Command(Base_Cog):
|
|||||||
return choices
|
return choices
|
||||||
|
|
||||||
@app_commands.command(name = "reload_all", description = "Reloads all cogs")
|
@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):
|
async def reload_all(self, ctx: discord.Interaction):
|
||||||
if self.__reload_running:
|
if self.__reload_running:
|
||||||
await ctx.response.send_message("Reload is allready being executed", ephemeral = True)
|
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.command(name = "reload", description = "Reload specific cog")
|
||||||
@app_commands.check(Maintenance_Command.handle_check)
|
|
||||||
@app_commands.autocomplete(cog_name = autocomplete_cog)
|
@app_commands.autocomplete(cog_name = autocomplete_cog)
|
||||||
async def reload(self, ctx: discord.Interaction, cog_name:str):
|
async def reload(self, ctx: discord.Interaction, cog_name:str):
|
||||||
if self.__reload_running:
|
if self.__reload_running:
|
||||||
|
|||||||
Reference in New Issue
Block a user