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
| Category | Commands | Access |
|---|---|---|
| Rich Order Flow | /order | Any registered user |
| Orders | /orders | Any registered user |
| Orders (legacy) | /order-start, /order-item, /order-shipping, /order-payment, /order-submit, /payment-confirm | Any registered user |
| Inventory | /catalog, /stock | Any registered user |
| Inventory Admin | /restock, /add-item | Admin (runtime role check) |
| Products | /product-list, /product-add, /product-update | Admin |
| Addresses | /address-list, /address-add, /address-update | Any registered user |
| Preferences | /dm-prefs, /email-prefs | Any registered user |
| Shipment | /ship, /buy-label | Admin |
| Refund | /refund | Admin |
| Discount | /discount-assign, /discount-revoke | Admin |
| Notify | /notify | Admin |
| Help | /help | Anyone |
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:
| ID | Triggered 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.
| Option | Type | Required | Description |
|---|---|---|---|
| productId | string | No | Pre-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.
| Option | Type | Required | Description |
|---|---|---|---|
| product | string | Yes | Product name or ID (autocomplete) |
/restock (admin)
Adds units to a product's inventory.
| Option | Type | Required | Description |
|---|---|---|---|
| product | string | Yes | Product name or ID (autocomplete) |
| quantity | integer | Yes | Units 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.
| Option | Type | Required | Description |
|---|---|---|---|
| order | string | Yes | Order ID (autocomplete) |
| carrier | string | Yes | Carrier name (e.g. USPS, UPS) |
| tracking | string | Yes | Tracking number |
/buy-label (admin)
Purchases a shipping label via EasyPost for a given order.
| Option | Type | Required | Description |
|---|---|---|---|
| order | string | Yes | Order ID (autocomplete) |
| service | string | No | Carrier service code (e.g. USPS_PRIORITY) |
Refund
/refund (admin)
Issues a refund for an order.
| Option | Type | Required | Description |
|---|---|---|---|
| order | string | Yes | Order ID (autocomplete) |
| reason | string | Yes | Reason (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.
| Option | Type | Required | Description |
|---|---|---|---|
| discountId | string | Yes | Discount code or ID (autocomplete) |
| customerId | string | Yes | Customer ID or Discord user ID |
| rule | string | Yes | one_time / next_n / forever |
| totalAllowed | integer | No | Uses allowed (required for one_time / next_n; min 1) |
| expiresAt | string | No | Expiry date in ISO 8601 (e.g. 2026-12-31) |
/discount-revoke (admin)
Revokes an existing discount assignment.
| Option | Type | Required | Description |
|---|---|---|---|
| assignmentId | string | Yes | Assignment 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.
| Option | Type | Required | Description |
|---|---|---|---|
| productId | string | Yes | Product ID |
| name | string | Yes | Product name |
| sku | string | Yes | SKU |
| quantity | integer | Yes | Quantity |
| unitPriceCents | integer | Yes | Unit price (cents) |
| currency | string | Yes | Currency code |
/order-shipping
Sets the shipping address.
| Option | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Recipient name |
| line1 | string | Yes | Street address |
| city | string | Yes | City |
| state | string | Yes | State |
| postalCode | string | Yes | ZIP/postal code |
| country | string | Yes | Country code |
/order-payment
Sets the payment method.
| Option | Type | Required | Description |
|---|---|---|---|
| paymentMethod | string | Yes | PAYPAL / CASHAPP_PAY / CASHAPP_P2P / ZELLE |
/order-submit
Submits the current order session.
/payment-confirm (admin)
Confirms payment has been received.
| Option | Type | Required | Description |
|---|---|---|---|
| orderId | string | Yes | Order ID |
Product Commands (Admin)
/product-list
Lists all products for the tenant. Admin only.
/product-add
Adds a new product. Admin only.
| Option | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Product name |
| sku | string | Yes | SKU code |
| priceCents | integer | Yes | Price in cents |
| description | string | No | Product description |
/product-update
Updates an existing product. Admin only.
| Option | Type | Required | Description |
|---|---|---|---|
| productId | string | Yes | Product ID |
| name | string | No | New name |
| sku | string | No | New SKU |
| priceCents | integer | No | New price |
| description | string | No | New description |
| isActive | boolean | No | Active status |
Address Commands
/address-list
Lists saved addresses for the current user.
/address-add
Adds a new address.
| Option | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Label (e.g. Home) |
| line1 | string | Yes | Street address |
| line2 | string | No | Apt/suite |
| city | string | Yes | City |
| state | string | Yes | State |
| postalCode | string | Yes | ZIP/postal code |
| country | string | Yes | Country code |
| phone | string | No | Phone number |
/address-update
Updates an address.
| Option | Type | Required | Description |
|---|---|---|---|
| addressId | string | Yes | Address ID |
| setDefault | boolean | No | Set 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:
| ID | Triggered 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.
| Option | Type | Required | Description |
|---|---|---|---|
| message | string | Yes | Message to send |
| target | string | No | channel 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