Skip to content

Commit

Permalink
Adds /extension list_disabled to list all disabled extensions (#1085)
Browse files Browse the repository at this point in the history
* Adds /extension list_disabled to list all disabled extensions

* Add handling for no disabled extensions
  • Loading branch information
ajax146 authored Jul 22, 2024
1 parent a71a092 commit f0dc3da
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions techsupport_bot/commands/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import discord
import ui
from core import auxiliary, cogs
from discord import app_commands
from discord.ext import commands

if TYPE_CHECKING:
Expand All @@ -35,8 +36,43 @@ async def setup(bot: bot.TechSupportBot) -> None:
class ExtensionControl(cogs.BaseCog):
"""
The class that holds the extension commands
Attrs:
extension_app_command_group (app_commands.Group): The group for the /extension commands
"""

extension_app_command_group = app_commands.Group(
name="extension", description="...", extras={"module": "extension"}
)

@extension_app_command_group.command(
name="list_disabled",
description="Lists all disabled extensions in the current server",
extras={"module": "extension"},
)
async def list_disabled(self: Self, interaction: discord.Interaction) -> None:
"""This will read the current guild config and list all the
extensions that are currently disabled
Args:
interaction (discord.Interaction): The interaction that triggered the slash command
"""
config = self.bot.guild_configs[str(interaction.guild.id)]
missing_extensions = [
item
for item in self.bot.extension_name_list
if item not in config.enabled_extensions
]
if len(missing_extensions) == 0:
embed = auxiliary.prepare_confirm_embed(
message="No currently loaded extensions are disabled"
)
else:
embed = auxiliary.prepare_confirm_embed(
message=f"Disabled extensions: {missing_extensions}"
)
await interaction.response.send_message(embed=embed)

@commands.check(auxiliary.bot_admin_check_context)
@commands.group(
name="extension",
Expand Down

0 comments on commit f0dc3da

Please sign in to comment.