Bot Config
Source: src/data/bot-config/
Service
createBotConfigService / BotConfigService
Factory: createBotConfigService(repository: BotConfigRepository) — returns BotConfigService.
Creates tenant-scoped bot config orchestration with guild uniqueness checks.
| Method | Parameters | Returns | Description |
|---|---|---|---|
| upsertForTenant | (ctx: RequestContext, input: BotConfigCreateInput) | Promise<BotConfigRecord> | Creates or updates the tenant's bot config; rejects guild collisions across tenants; performs idempotent replay checks for unchanged input |
| getForTenant | (ctx: RequestContext) | Promise<BotConfigRecord | null> | Returns the config for the current tenant |
| resolveTenantByGuildId | (guildId: string) | Promise<GuildTenantMapping | null> | Resolves tenant mapping from a Discord guild id |
| resolveTenantByDiscordUserId | (discordUserId: string) | Promise<GuildTenantMapping | null> | Resolves tenant mapping from a registered Discord user id |
| resolveTenantForInteraction | (input: { guildId?: string, discordUserId?: string }) | Promise<InteractionTenantResolution | null> | Resolves tenant for a Discord interaction, preferring guild over user lookup |
| registerDiscordUserForTenant | (ctx: RequestContext, discordUserId: string) | Promise<BotConfigRecord> | Registers a Discord user id to the current tenant's bot config |
| resolvePaymentInstruction | (ctx: RequestContext, method: PaymentMethod) | Promise<string> | Returns payment instructions for a given payment method, falling back to default instructions |
Repository
BotConfigRepository
| Method | Parameters | Returns |
|---|---|---|
| getById | (ctx: RequestContext, id: string) | Promise<BotConfigRecord | null> |
| getByTenant | (ctx: RequestContext) | Promise<BotConfigRecord | null> |
| getByGuildId | (guildId: string) | Promise<BotConfigRecord | null> |
| listByDiscordUserId | (discordUserId: string) | Promise<BotConfigRecord[]> |
| listByTenant | (ctx: RequestContext) | Promise<BotConfigRecord[]> |
| create | (ctx: RequestContext, input: BotConfigCreateInput & { id: string, registeredDiscordUserIds?: string[] }) | Promise<BotConfigRecord> |
| update | (ctx: RequestContext, id: string, patch: BotConfigPatchInput) | Promise<BotConfigRecord> |
| registerDiscordUser | (ctx: RequestContext, id: string, discordUserId: string) | Promise<BotConfigRecord> |
| delete | (ctx: RequestContext, id: string) | Promise<void> |
Validators
botConfigSchema
| Field | Type | Required | Default |
|---|---|---|---|
| tenantId | string | Yes | — |
| guildId | string | Yes | — |
| defaultOrderChannelId | string | No | — |
| announcementChannelId | string | No | — |
| adminRoleIds | string[] | No | [] |
| staffRoleIds | string[] | No | [] |
| responseMode | enum('EPHEMERAL', 'DM') | No | 'EPHEMERAL' |
| lowInventoryThreshold | number (int, min 0) | No | 5 |
| enabledPaymentMethods | PaymentMethod[] | No | [] |
| paymentInstructions | string | No | '' |
| paymentInstructionsByMethod | Record<string, string> | No | {} |
| registeredDiscordUserIds | string[] | No | [] |
| defaultQtyVisibility | enum('public' | 'private') | No | 'public' |
| defaultProductImageUrl | string (URL) | No | — |
| createdAt | Date (coerced) | Yes | — |
| updatedAt | Date (coerced) | Yes | — |
Inferred Types
BotConfig—z.infer<typeof botConfigSchema>