fix(discord): add warning log when slash command rejected due to missing allowlist
When a Discord slash command is rejected because no user allowlist is configured, log a helpful warning message to assist users in debugging the issue. The warning includes: - The user ID that was rejected - Instructions to configure channels.discord.guilds.<id>.users or dm.allowFrom This maintains the secure-by-default behavior (deny when no allowlist) while making it easier for users to understand why commands are being rejected. Example log: discord: slash command rejected for user 123456 - no allowlist configured. Configure channels.discord.guilds.<id>.users or channels.discord.dm.allowFrom to allow users.
This commit is contained in:
parent
9daa846457
commit
8b8fce5371
@ -38,6 +38,7 @@ import {
|
|||||||
readChannelAllowFromStore,
|
readChannelAllowFromStore,
|
||||||
upsertChannelPairingRequest,
|
upsertChannelPairingRequest,
|
||||||
} from "../../pairing/pairing-store.js";
|
} from "../../pairing/pairing-store.js";
|
||||||
|
import { logVerbose } from "../../globals.js";
|
||||||
import { resolveAgentRoute } from "../../routing/resolve-route.js";
|
import { resolveAgentRoute } from "../../routing/resolve-route.js";
|
||||||
import { loadWebMedia } from "../../web/media.js";
|
import { loadWebMedia } from "../../web/media.js";
|
||||||
import { chunkDiscordTextWithMode } from "../chunk.js";
|
import { chunkDiscordTextWithMode } from "../chunk.js";
|
||||||
@ -656,6 +657,14 @@ async function dispatchDiscordCommandInteraction(params: {
|
|||||||
modeWhenAccessGroupsOff: "configured",
|
modeWhenAccessGroupsOff: "configured",
|
||||||
});
|
});
|
||||||
if (!commandAuthorized) {
|
if (!commandAuthorized) {
|
||||||
|
// Log warning when no allowlist is configured to help users debug
|
||||||
|
const anyAuthorizerConfigured = authorizers.some((entry) => entry.configured);
|
||||||
|
if (!anyAuthorizerConfigured) {
|
||||||
|
logVerbose(
|
||||||
|
`discord: slash command rejected for user ${user.id} - no allowlist configured. ` +
|
||||||
|
`Configure channels.discord.guilds.<id>.users or channels.discord.dm.allowFrom to allow users.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
await respond("You are not authorized to use this command.", { ephemeral: true });
|
await respond("You are not authorized to use this command.", { ephemeral: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user