From a23815998cb76c5ba9bb68c0be63c83f41ed295b Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Tue, 4 Oct 2022 13:23:15 +0200 Subject: [PATCH] Improved some commands #54 --- src/modules/base/base_module.py | 2 -- src/modules/base/command/help_command.py | 9 +++++++++ .../{base => moderator}/command/user_info_command.py | 0 src/modules/moderator/moderator_module.py | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) rename src/modules/{base => moderator}/command/user_info_command.py (100%) diff --git a/src/modules/base/base_module.py b/src/modules/base/base_module.py index ef52df05..d4257cd8 100644 --- a/src/modules/base/base_module.py +++ b/src/modules/base/base_module.py @@ -11,7 +11,6 @@ from modules.base.command.afk_command import AFKCommand from modules.base.command.help_command import HelpCommand from modules.base.command.info_command import InfoCommand from modules.base.command.ping_command import PingCommand -from modules.base.command.user_info_command import UserInfoCommand from modules.base.events.base_on_command_error_event import BaseOnCommandErrorEvent from modules.base.events.base_on_command_event import BaseOnCommandEvent from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent @@ -36,7 +35,6 @@ class BaseModule(ModuleABC): self._dc.add_command(HelpCommand) self._dc.add_command(InfoCommand) self._dc.add_command(PingCommand) - self._dc.add_command(UserInfoCommand) # events self._dc.add_event(DiscordEventTypesEnum.on_command.value, BaseOnCommandEvent) self._dc.add_event(DiscordEventTypesEnum.on_command_error.value, BaseOnCommandErrorEvent) diff --git a/src/modules/base/command/help_command.py b/src/modules/base/command/help_command.py index a903e70a..b85dacd8 100644 --- a/src/modules/base/command/help_command.py +++ b/src/modules/base/command/help_command.py @@ -1,6 +1,10 @@ +from typing import List + +import discord from cpl_core.configuration import ConfigurationABC from cpl_discord.command import DiscordCommandABC from cpl_discord.service import DiscordBotServiceABC +from discord import app_commands from discord.ext import commands from discord.ext.commands import Context @@ -41,3 +45,8 @@ class HelpCommand(DiscordCommandABC): is_persistent = persistent_flag == '--stay' await self._message_service.send_ctx_msg(ctx, settings.help_command_reference_url, is_persistent=is_persistent) self._logger.trace(__name__, f'Finished help command') + + @help.autocomplete('persistent_flag') + async def help_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: + flags = ['--stay'] + return [app_commands.Choice(name=key, value=key) for key in flags] diff --git a/src/modules/base/command/user_info_command.py b/src/modules/moderator/command/user_info_command.py similarity index 100% rename from src/modules/base/command/user_info_command.py rename to src/modules/moderator/command/user_info_command.py diff --git a/src/modules/moderator/moderator_module.py b/src/modules/moderator/moderator_module.py index e47d994d..c981fc2d 100644 --- a/src/modules/moderator/moderator_module.py +++ b/src/modules/moderator/moderator_module.py @@ -6,6 +6,7 @@ from cpl_discord.service.discord_collection_abc import DiscordCollectionABC from bot_core.abc.module_abc import ModuleABC from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum from modules.moderator.command.purge_command import PurgeCommand +from modules.moderator.command.user_info_command import UserInfoCommand class ModeratorModule(ModuleABC): @@ -19,4 +20,5 @@ class ModeratorModule(ModuleABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC): # commands self._dc.add_command(PurgeCommand) + self._dc.add_command(UserInfoCommand) # events