Add config option to disable Discord slash commands

Add discord.slash_commands config option (default: true) to allow
users to disable Discord slash command registration when running
alongside other bots that use the same command names.

When set to false in config.yaml:
  discord:
    slash_commands: false

The _register_slash_commands() call is skipped while text-based
parsing of /commands continues to work normally.

Fixes #4881
This commit is contained in:
fuleinist 2026-04-21 02:06:52 +08:00 committed by Teknium
parent ee54e20c29
commit e371af1df2

View file

@ -527,6 +527,7 @@ class DiscordAdapter(BasePlatformAdapter):
# Reply threading mode: "off" (no replies), "first" (reply on first # Reply threading mode: "off" (no replies), "first" (reply on first
# chunk only, default), "all" (reply-reference on every chunk). # chunk only, default), "all" (reply-reference on every chunk).
self._reply_to_mode: str = getattr(config, 'reply_to_mode', 'first') or 'first' self._reply_to_mode: str = getattr(config, 'reply_to_mode', 'first') or 'first'
self._slash_commands: bool = self.config.extra.get("slash_commands", True)
async def connect(self) -> bool: async def connect(self) -> bool:
"""Connect to Discord and start receiving events.""" """Connect to Discord and start receiving events."""
@ -744,7 +745,8 @@ class DiscordAdapter(BasePlatformAdapter):
) )
# Register slash commands # Register slash commands
self._register_slash_commands() if self._slash_commands:
self._register_slash_commands()
# Start the bot in background # Start the bot in background
self._bot_task = asyncio.create_task(self._client.start(self.config.token)) self._bot_task = asyncio.create_task(self._client.start(self.config.token))