Skip to main content

Discord Commands

Reference for the unified Discord command router and notify service.

Embed and Component Types

Source: src/data/discord-commands/discord-embed.types.ts

TypeDescription
DiscordEmbedRich message embed (title, description, fields)
DiscordButtonButton component (type 2) with custom_id or url
DiscordStringSelectSelect menu (type 3) for options
DiscordTextInputModal text input (type 4)
DiscordModalDataModal response (type 9)

DISCORD_BUTTON_STYLE provides PRIMARY, SECONDARY, SUCCESS, DANGER, LINK.

Custom ID Constants

Source: src/data/discord-commands/discord-custom-id.constants.ts

Format: {prefix}:{action}:{params} (max 100 chars). Prefixes: order, address. Actions include add, step, use-address, address:confirm, address:new, address:edit, address:submit. Steps: products, shipping, payment, submit. Use buildCustomId() and parseCustomId() helpers.

Command Router

Source: src/data/discord-commands/discord-command-router.ts

Routes slash commands, message components (buttons, selects), and modal submits to order flow, product management, address management, notify, and help.

execute

AspectDetails
Input{ tenantId, guildId?, channelId?, discordUserId, commandName, rawOptions, memberRoleIds? }
OutputPromise<DiscordCommandResult> (content/embeds/components or modal)
Side effectsDelegates to order router, product repo, customer service, or notify service as appropriate.

executeComponent

AspectDetails
Input{ tenantId, guildId?, channelId?, discordUserId, customId, values? }
OutputPromise<DiscordCommandResult>
Side effectsHandles order flow steps, address select, product add, payment, submit.

executeModal

AspectDetails
Input{ tenantId, guildId?, channelId?, discordUserId, customId, components }
OutputPromise<DiscordCommandResult>
Side effectsHandles address add/edit and order shipping address form submission.

DiscordNotifyService

Source: src/data/discord-commands/discord-notify.service.ts

send

AspectDetails
Inputctx, { message, target: 'channel' | 'dm', channelId?, tenantId }, { botToken, getDiscordIdsForTenant }
OutputPromise<{ sent: number, failed: number, errors: string[] }>
Side effectsSends messages via Discord REST API. Channel target posts to the given channel. DM target sends to each tenant customer with a Discord ID.

Error Constants

Source: src/data/discord-commands/discord-commands.errors.ts

ConstantDescription
NOTIFY_BOT_TOKEN_REQUIREDDISCORD_BOT_TOKEN is required for notify delivery.
NOTIFY_CHANNEL_REQUIREDChannel ID is required for channel target.
NOTIFY_DM_CREATE_FAILEDFailed to create DM channel.
NOTIFY_SEND_FAILEDFailed to send message.