fix(discord): add DIRECT_MESSAGES intent to enable DM support

* fix(discord): add DIRECT_MESSAGES intent to enable DM support

* fix(discord): allow DMs to bypass guild_id filter

---------

Co-authored-by: Moeblack <moeblack@example.com>
This commit is contained in:
Nakano Kenji 2026-02-16 04:00:11 +08:00 committed by GitHub
parent 9b2f90018c
commit 021d03eb0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -146,7 +146,7 @@ impl Channel for DiscordChannel {
"op": 2, "op": 2,
"d": { "d": {
"token": self.bot_token, "token": self.bot_token,
"intents": 33281, // GUILDS | GUILD_MESSAGES | MESSAGE_CONTENT | DIRECT_MESSAGES "intents": 37377, // GUILDS | GUILD_MESSAGES | MESSAGE_CONTENT | DIRECT_MESSAGES
"properties": { "properties": {
"os": "linux", "os": "linux",
"browser": "zeroclaw", "browser": "zeroclaw",
@ -258,11 +258,14 @@ impl Channel for DiscordChannel {
// Guild filter // Guild filter
if let Some(ref gid) = guild_filter { if let Some(ref gid) = guild_filter {
let msg_guild = d.get("guild_id").and_then(serde_json::Value::as_str).unwrap_or(""); let msg_guild = d.get("guild_id").and_then(serde_json::Value::as_str);
if msg_guild != gid { // DMs have no guild_id — let them through; for guild messages, enforce the filter
if let Some(g) = msg_guild {
if g != gid {
continue; continue;
} }
} }
}
let content = d.get("content").and_then(|c| c.as_str()).unwrap_or(""); let content = d.get("content").and_then(|c| c.as_str()).unwrap_or("");
if content.is_empty() { if content.is_empty() {