Discord Types
This file defines all core TypeScript types and interfaces used throughout the Discord integration for the @sodacore/core
library. These types provide strong typing for configuration, authentication, controller metadata, argument injection, token handling, and interactive prompts.
Features
- Configuration Types: Defines the structure for Discord bot configuration options.
- Authentication Types: Types for user and guild member authentication functions and guards.
- Controller Metadata: Types for controller and method metadata, supporting routing and authorization.
- Argument Injection: Types for describing how method arguments are injected in Discord controllers.
- Token Handling: Types for OAuth token results.
- Prompt Types: Types for interactive prompts, choices, and confirmation dialogs in Discord interactions.
Usage
Import the types you need for strong typing in your Discord modules, providers, controllers, and scripts.
import type {
IConfig,
IAuthFunction,
IRouterControllerItem,
IRouterControllerMethodItem,
IControllerMethodArgItem,
ITokenResult,
IPromptChoiceItem,
IAllowedInteractionType,
IPromptsConfirmOptions,
IPromptsChoiceOptions
} from './types';
API Overview
Authentication
IAuthFunctionUser
Function type for authenticating a DiscordUser
.IAuthFunctionGuildMember
Function type for authenticating a DiscordGuildMember
.IAuthFunction
Function type for authenticating either aUser
orGuildMember
.IAuthFunctionItem
Describes an authentication guard, specifying the context (user
orguildmember
) and the callback function.
Configuration
IConfig
Discord bot configuration options, including token, client ID/secret, base URL, scopes, guild ID, client options, events, and command registration location.
Controller Metadata
IRouterControllerMethodItem
Describes a controller method, including its key, unique identifier, type, subtype, and authentication guards.IRouterControllerItem
Describes a controller, including its name, class name, methods, and module instance.
Argument Injection
IControllerMethodArgItem
Describes how a method argument should be injected, including its type (e.g., interaction, user, guild, channel, client, query, option, field), index, and optional name/format.
OAuth Token Handling
ITokenResult
Describes the result of an OAuth token exchange, including token type, expiration, refresh token, access token, and scope.
Prompts & Interactions
IPromptChoiceItem
Describes a choice option for a prompt (label and value).IAllowedInteractionType
Union type of all Discord.js interaction types supported by prompts (chat input, button, select menu, context menu, modal submit).IPromptsQuestionOptions
Options for prompt questions, including timeout, description, ephemeral flag, timestamp, and embed fields.IPromptsConfirmOptions
ExtendsIPromptsQuestionOptions
with custom labels for accept/reject buttons.IPromptsChoiceOptions
ExtendsIPromptsQuestionOptions
with a placeholder for select menus.
Notes
- These types are intended for internal use within the Sodacore Discord integration, but can be imported and used in custom modules and controllers for type safety.
- The prompt-related types are used by the
PromptsHelper
provider to create interactive Discord UI components. - Controller and argument metadata types are used for routing, argument injection, and authentication in Discord event handling.