Skip to main content

Discord Bot Commands

Ledgerline's Discord bot supports orders, inventory browsing, product management, discounts, shipments, refunds, and notifications. Commands are routed through createDiscordCommandRouter and wired via src/endpoints/discord.endpoint.ts.

Registering Commands​

Before commands appear in Discord, register them with the Discord API:

DISCORD_BOT_TOKEN=your_bot_token \
DISCORD_APPLICATION_ID=your_app_id \
pnpm discord:register-commands

For guild-specific registration (faster for testing), add DISCORD_GUILD_ID.

To inspect the command payloads without hitting Discord:

node scripts/discord-register-commands.mjs --dry-run

Command Summary​

CategoryCommandsAccess
Rich Order Flow/orderAny registered user
Orders/ordersAny registered user
Orders (legacy)/order-start, /order-item, /order-shipping, /order-payment, /order-submit, /payment-confirmAny registered user
Inventory/catalog, /stockAny registered user
Inventory Admin/restock, /add-itemAdmin (runtime role check)
Products/product-list, /product-add, /product-updateAdmin
Addresses/address-list, /address-add, /address-updateAny registered user
Preferences/dm-prefs, /email-prefsAny registered user
Shipment/ship, /buy-labelAdmin
Refund/refundAdmin
Discount/discount-assign, /discount-revokeAdmin
Notify/notifyAdmin
Help/helpAnyone

Orders​

/orders​

Lists your last 10 orders. The response is ephemeral (only you can see it). Each order shows the order number, status, total, and a View details button that expands a full itemized embed.

When you have more than 10 orders, Previous and Next buttons appear for pagination.

No slash options.

Component IDs:

IDTriggered by
orders:detail:<orderId>:<page>View details button per order row
orders:page:<page>Previous / Next pagination buttons

Rich Order Flow​

/order​

Starts (or resumes) an interactive order session. Opens a product select menu. The optional productId argument skips the select and jumps straight to quantity entry — used by the Catalog "Order" button.

OptionTypeRequiredDescription
productIdstringNoPre-select a product (autocomplete)

Inventory​

/catalog​

Displays active, published products with prices and availability. Paginated (10 per page). Each product has an "Order" button that enters the rich order flow.

No options.

/stock​

Shows stock level and product details for a specific product.

OptionTypeRequiredDescription
productstringYesProduct name or ID (autocomplete)

/restock (admin)​

Adds units to a product's inventory.

OptionTypeRequiredDescription
productstringYesProduct name or ID (autocomplete)
quantityintegerYesUnits to add (min 1)

/add-item (admin)​

Opens a modal to create a new draft product. The modal collects: name, description, price (cents), cost (cents), and initial quantity + visibility. The product is created in draft state; publish via AdminJS.

No slash options (all input via modal).


Shipment​

/ship (admin)​

Marks an order as shipped.

OptionTypeRequiredDescription
orderstringYesOrder ID (autocomplete)
carrierstringYesCarrier name (e.g. USPS, UPS)
trackingstringYesTracking number

/buy-label (admin)​

Purchases a shipping label via EasyPost for a given order.

OptionTypeRequiredDescription
orderstringYesOrder ID (autocomplete)
servicestringNoCarrier service code (e.g. USPS_PRIORITY)

Refund​

/refund (admin)​

Issues a refund for an order.

OptionTypeRequiredDescription
orderstringYesOrder ID (autocomplete)
reasonstringYesReason (max 500 chars)

Discount​

/discount-assign (admin)​

Assigns a discount to a customer. The rule controls how many orders the discount applies to. totalAllowed is required for one_time and next_n rules.

OptionTypeRequiredDescription
discountIdstringYesDiscount code or ID (autocomplete)
customerIdstringYesCustomer ID or Discord user ID
rulestringYesone_time / next_n / forever
totalAllowedintegerNoUses allowed (required for one_time / next_n; min 1)
expiresAtstringNoExpiry date in ISO 8601 (e.g. 2026-12-31)

/discount-revoke (admin)​

Revokes an existing discount assignment.

OptionTypeRequiredDescription
assignmentIdstringYesAssignment ID to revoke (autocomplete)

Order Flow (legacy)​

These commands were the original multi-step order flow. They remain registered for back-compat. The rich /order flow is preferred for new users.

/register / /order-start​

Starts a new order session.

/order-item​

Adds an item to the current session.

OptionTypeRequiredDescription
productIdstringYesProduct ID
namestringYesProduct name
skustringYesSKU
quantityintegerYesQuantity
unitPriceCentsintegerYesUnit price (cents)
currencystringYesCurrency code

/order-shipping​

Sets the shipping address.

OptionTypeRequiredDescription
namestringYesRecipient name
line1stringYesStreet address
citystringYesCity
statestringYesState
postalCodestringYesZIP/postal code
countrystringYesCountry code

/order-payment​

Sets the payment method.

OptionTypeRequiredDescription
paymentMethodstringYesPAYPAL / CASHAPP_PAY / CASHAPP_P2P / ZELLE

/order-submit​

Submits the current order session.

/payment-confirm (admin)​

Confirms payment has been received.

OptionTypeRequiredDescription
orderIdstringYesOrder ID

Product Commands (Admin)​

/product-list​

Lists all products for the tenant. Admin only.

/product-add​

Adds a new product. Admin only.

OptionTypeRequiredDescription
namestringYesProduct name
skustringYesSKU code
priceCentsintegerYesPrice in cents
descriptionstringNoProduct description

/product-update​

Updates an existing product. Admin only.

OptionTypeRequiredDescription
productIdstringYesProduct ID
namestringNoNew name
skustringNoNew SKU
priceCentsintegerNoNew price
descriptionstringNoNew description
isActivebooleanNoActive status

Address Commands​

/address-list​

Lists saved addresses for the current user.

/address-add​

Adds a new address.

OptionTypeRequiredDescription
namestringYesLabel (e.g. Home)
line1stringYesStreet address
line2stringNoApt/suite
citystringYesCity
statestringYesState
postalCodestringYesZIP/postal code
countrystringYesCountry code
phonestringNoPhone number

/address-update​

Updates an address.

OptionTypeRequiredDescription
addressIdstringYesAddress ID
setDefaultbooleanNoSet as default address

Preferences​

/dm-prefs​

Shows your current Discord DM notification preferences and lets you toggle each event type. The response is ephemeral. See Guild Member Notifications.

No slash options.

/email-prefs​

Shows your current email notification preferences and lets you toggle each event type. The response is ephemeral. Requires your customer profile to have an email address on file for emails to be delivered.

No slash options.

Component IDs:

IDTriggered by
email-prefs:toggle:<key>Toggle button for each preference (orderReceived, paymentConfirmed, orderShipped, refunds)

Notify (Admin)​

/notify​

Sends a notification. Admin only.

  • channel (default): Posts to the channel where the command was invoked.
  • dm: Sends a DM to each customer with a Discord ID registered for the tenant.
OptionTypeRequiredDescription
messagestringYesMessage to send
targetstringNochannel or dm (default: channel)

Help​

/help​

Lists all available commands.


Sources​

  • Command router: src/data/discord-commands/discord-command-router.ts
  • Command constants: src/data/discord-commands/discord-commands.constants.ts
  • Registration script: scripts/discord-register-commands.mjs