hermes - ✅(Solved) Fix [Bug]: Discord native slash commands bypass DISCORD_ALLOWED_CHANNELS [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17724Fetched 2026-05-01 05:56:16
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×2closed ×1cross-referenced ×1

Error Message

Additional Logs / Traceback

No traceback. This is incorrect routing/authorization behavior.

Root Cause

Normal Discord message handling checks DISCORD_ALLOWED_CHANNELS and DISCORD_IGNORED_CHANNELS in gateway/platforms/discord.py.

Native slash commands go through _run_simple_slash(), which logs the interaction, builds a MessageEvent, and dispatches directly to handle_message(event) without applying the same allowed/ignored channel policy.

As a result, native slash interactions can execute in channels where ordinary Discord messages from the same bot would be ignored.

Fix Action

Fix / Workaround

In a multi-bot Discord deployment, two Hermes bots can both register native slash commands such as /reset. If the user selects Bot A's native slash command inside a channel/thread that only Bot B should handle, Bot A still dispatches the command and sends a response there, even when Bot A's DISCORD_ALLOWED_CHANNELS does not include that channel or the thread's parent channel.

Native slash commands go through _run_simple_slash(), which logs the interaction, builds a MessageEvent, and dispatches directly to handle_message(event) without applying the same allowed/ignored channel policy.

Apply the same Discord channel allow/ignore policy before dispatching native slash commands.

PR fix notes

PR #17715: fix(gateway): apply Discord channel policy to slash commands

Description (problem / solution / changelog)

What does this PR do?

Applies Discord channel allow/ignore policy checks to native slash command interactions before dispatching them to the gateway session handler. This prevents a bot whose DISCORD_ALLOWED_CHANNELS excludes a channel or thread parent from still executing native slash commands there.

The change also routes normal Discord messages through the same helper so message and slash command channel policy behavior stays aligned. DM slash interactions keep the same allowlist exemption as DM messages.

The /thread native slash command is covered too, since it creates Discord-side state directly instead of going through _run_simple_slash().

Related Issue

Fixes #17724

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • gateway/platforms/discord.py: add shared Discord channel policy helpers and reject blocked native slash commands before deferring or dispatching.
  • gateway/platforms/discord.py: apply the same policy to /thread, which bypasses _run_simple_slash().
  • tests/gateway/test_discord_slash_commands.py: add regression coverage for native slash commands in allowed, non-allowed, ignored-channel, DM, and /thread contexts.

How to Test

  1. Configure a Discord bot with DISCORD_ALLOWED_CHANNELS set to one parent channel.
  2. Invoke one of its native slash commands, such as /reset, from a thread whose parent channel is not allowlisted.
  3. Confirm the command is rejected ephemerally and does not dispatch to handle_message.

Targeted Discord tests passed locally:

venv/bin/python -m pytest tests/gateway/test_discord_slash_commands.py tests/gateway/test_discord_allowed_channels.py tests/gateway/test_discord_channel_controls.py tests/gateway/test_discord_free_response.py tests/gateway/test_discord_reply_mode.py -q

Result: 115 passed in 4.20s

Full suite was also run locally against this branch and against current origin/main for comparison:

venv/bin/python -m pytest tests/ -q --tb=short --junitxml=/tmp/hermes-pr-full.xml

Branch result: 120 failed, 17813 passed, 48 skipped, 226 warnings in 193.31s

Baseline origin/main result with the same command/environment: 131 failed, 17797 passed, 48 skipped, 225 warnings in 243.22s

The full suite is not currently clean on origin/main; the targeted Discord channel-policy regression tests pass.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: Linux

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact — N/A, Discord gateway logic only
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Screenshots / Logs

115 passed in 4.20s

Branch full suite:
120 failed, 17813 passed, 48 skipped, 226 warnings in 193.31s

origin/main full suite baseline:
131 failed, 17797 passed, 48 skipped, 225 warnings in 243.22s

Changed files

  • gateway/platforms/discord.py (modified, +79/-17)
  • tests/gateway/test_discord_slash_commands.py (modified, +112/-1)

Code Example

Bot A:
DISCORD_ALLOWED_CHANNELS=<bot-a-channel-id>

Bot B:
DISCORD_ALLOWED_CHANNELS=<bot-b-channel-id>

Interaction channel:
<thread-id-under-bot-b-channel>
Parent channel:
<bot-b-channel-id>
RAW_BUFFERClick to expand / collapse

Bug Description

Discord native slash commands can bypass DISCORD_ALLOWED_CHANNELS / DISCORD_IGNORED_CHANNELS.

In a multi-bot Discord deployment, two Hermes bots can both register native slash commands such as /reset. If the user selects Bot A's native slash command inside a channel/thread that only Bot B should handle, Bot A still dispatches the command and sends a response there, even when Bot A's DISCORD_ALLOWED_CHANNELS does not include that channel or the thread's parent channel.

This is the same class of issue as #6033, but for Discord native slash interactions instead of Telegram slash commands.

Steps to Reproduce

  1. Run two Discord Hermes bots in the same server.
  2. Configure Bot A with DISCORD_ALLOWED_CHANNELS=<bot-a-channel-id>.
  3. Configure Bot B with DISCORD_ALLOWED_CHANNELS=<bot-b-channel-id>.
  4. Let both bots register native slash commands like /reset.
  5. In a thread under Bot B's allowed channel, invoke Bot A's native /reset command from Discord's slash command picker.

Expected Behavior

Bot A should reject or ignore the native slash command because the interaction channel/thread parent is not included in Bot A's DISCORD_ALLOWED_CHANNELS.

Native Discord slash commands should apply the same channel allow/ignore policy as normal Discord messages.

Actual Behavior

Bot A handles the native slash command and posts a response in Bot B's thread. Bot B does not receive that slash interaction, because Discord native slash interactions are delivered to the selected application rather than broadcast as ordinary channel messages.

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform

Discord

Debug Report

Not uploaded. The local reproduction used private Discord channel IDs, so this report intentionally uses placeholders instead of real IDs.

Example sanitized setup:

Bot A:
DISCORD_ALLOWED_CHANNELS=<bot-a-channel-id>

Bot B:
DISCORD_ALLOWED_CHANNELS=<bot-b-channel-id>

Interaction channel:
<thread-id-under-bot-b-channel>
Parent channel:
<bot-b-channel-id>

Operating System

Linux

Python Version

3.11+

Hermes Version

0.11.0 / current main branch behavior observed in code

Additional Logs / Traceback

No traceback. This is incorrect routing/authorization behavior.

Root Cause Analysis

Normal Discord message handling checks DISCORD_ALLOWED_CHANNELS and DISCORD_IGNORED_CHANNELS in gateway/platforms/discord.py.

Native slash commands go through _run_simple_slash(), which logs the interaction, builds a MessageEvent, and dispatches directly to handle_message(event) without applying the same allowed/ignored channel policy.

As a result, native slash interactions can execute in channels where ordinary Discord messages from the same bot would be ignored.

Proposed Fix

Apply the same Discord channel allow/ignore policy before dispatching native slash commands.

A draft PR is available: https://github.com/NousResearch/hermes-agent/pull/17715

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Apply the same Discord channel allow/ignore policy to native slash commands before dispatching them.

Guidance

  • Review the _run_simple_slash() function in gateway/platforms/discord.py to understand how native slash commands are currently handled.
  • Modify the _run_simple_slash() function to check DISCORD_ALLOWED_CHANNELS and DISCORD_IGNORED_CHANNELS before dispatching the command.
  • Verify that the fix works by testing native slash commands in channels that should be allowed or ignored according to the bot's configuration.
  • Consider reviewing the draft PR (https://github.com/NousResearch/hermes-agent/pull/17715) for a potential solution.

Example

No code example is provided as the issue does not contain sufficient code context, but the fix should involve modifying the _run_simple_slash() function to apply the channel policy.

Notes

The fix should ensure that native slash commands follow the same channel allow/ignore policy as normal Discord messages, preventing unintended command execution in restricted channels.

Recommendation

Apply the workaround by modifying the _run_simple_slash() function to apply the channel policy, as this is a targeted fix for the identified issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: Discord native slash commands bypass DISCORD_ALLOWED_CHANNELS [1 pull requests, 2 comments, 2 participants]