feat(discord): add allowBots mention gating

This commit is contained in:
Shadow
2026-03-03 12:47:25 -06:00
parent b0bcea03db
commit 65816657c2
9 changed files with 164 additions and 6 deletions

View File

@@ -139,7 +139,9 @@ export async function preflightDiscordMessage(
return null;
}
const allowBots = params.discordConfig?.allowBots ?? false;
const allowBotsSetting = params.discordConfig?.allowBots;
const allowBotsMode =
allowBotsSetting === "mentions" ? "mentions" : allowBotsSetting === true ? "all" : "off";
if (params.botUserId && author.id === params.botUserId) {
// Always ignore own messages to prevent self-reply loops
return null;
@@ -166,7 +168,7 @@ export async function preflightDiscordMessage(
});
if (author.bot) {
if (!allowBots && !sender.isPluralKit) {
if (allowBotsMode === "off" && !sender.isPluralKit) {
logVerbose("discord: drop bot message (allowBots=false)");
return null;
}
@@ -656,6 +658,15 @@ export async function preflightDiscordMessage(
}
}
if (author.bot && !sender.isPluralKit && allowBotsMode === "mentions") {
const botMentioned = isDirectMessage || wasMentioned || implicitMention;
if (!botMentioned) {
logDebug(`[discord-preflight] drop: bot message missing mention (allowBots=mentions)`);
logVerbose("discord: drop bot message (allowBots=mentions, missing mention)");
return null;
}
}
const ignoreOtherMentions =
channelConfig?.ignoreOtherMentions ?? guildInfo?.ignoreOtherMentions ?? false;
if (