Discord: add allowBots config option (#802)
Co-authored-by: Shadow <shadow@clawd.bot>
This commit is contained in:
committed by
GitHub
parent
490cb834e5
commit
3467b0ba07
@@ -513,6 +513,8 @@ export type DiscordAccountConfig = {
|
||||
/** If false, do not start this Discord account. Default: true. */
|
||||
enabled?: boolean;
|
||||
token?: string;
|
||||
/** Allow bot-authored messages to trigger replies (default: false). */
|
||||
allowBots?: boolean;
|
||||
/**
|
||||
* Controls how guild channel messages are handled:
|
||||
* - "open": guild channels bypass allowlists; mention-gating applies
|
||||
|
||||
@@ -368,6 +368,7 @@ const DiscordAccountSchema = z.object({
|
||||
capabilities: z.array(z.string()).optional(),
|
||||
enabled: z.boolean().optional(),
|
||||
token: z.string().optional(),
|
||||
allowBots: z.boolean().optional(),
|
||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||
historyLimit: z.number().int().min(0).optional(),
|
||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||
|
||||
@@ -647,7 +647,17 @@ export function createDiscordMessageHandler(params: {
|
||||
try {
|
||||
const message = data.message;
|
||||
const author = data.author;
|
||||
if (!author || author.bot) return;
|
||||
if (!author) return;
|
||||
|
||||
const allowBots = discordConfig?.allowBots ?? false;
|
||||
if (author.bot) {
|
||||
// Always ignore own messages to prevent self-reply loops
|
||||
if (botUserId && author.id === botUserId) return;
|
||||
if (!allowBots) {
|
||||
logVerbose("discord: drop bot message (allowBots=false)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const isGuildMessage = Boolean(data.guild_id);
|
||||
const channelInfo = await resolveDiscordChannelInfo(
|
||||
|
||||
Reference in New Issue
Block a user