Creates a new Discord HTTPS Interaction Client.
Client configuration options.
Optional
debug?: booleanProtected
isReadonly
restREST API client instance used for interacting with Discord's HTTP API.
Registers an autocomplete interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
const weather = router.command(
async(builder) =>
builder
.setName("weather")
.setDescription("Query weather information!")
.addStringOption(option =>
option
.setName("city") // Option Name
.setDescription("City to get the weather for")
.setAutocomplete(true) // Enable autocomplete for this option
),
handler
);
router.autocomplete(weather.getAutoCompleteKey("city"), autocompleteMiddleware);
Registers a button interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers a channel select interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers a command with its associated middleware.
Function returning a SlashCommandBuilder.
Async functions. See GenericMiddleware for callback parameters.
an AutoCompleteKeyBuilder for autocomplete options.
Protected
debugPrints debug messages with a timestamp if debug mode is enabled.
Message parts to log.
Returns a request handler bound to the provided endpoint.
Example for making your own adapter, see these GitHub repositories:
GitHub repositories:
URL path where Discord will POST interactions (e.g. "/interactions").
Returns helpers for registering slash commands.
Log progress. Defaults to true.
An object containing:
globalSlashRegistrar
: Function to register commands globally.localSlashRegistrar(guildId: string)
: Function to register commands locally for a specific guild, requires the guild ID as a parameter.payload
: The payload returned from GET /applications/@me
.Starts listening for HTTP requests using the configured HttpAdapter.
The endpoint path (e.g. "/interactions"
).
Extra arguments passed to the adapter's listen
method.
Adapter-specific usage:
- Node.js Adapter: standard Node.js server arguments,
e.g., port
and optional callback:
ts client.listen("/interactions", 3000, () => { console.log("Server is active at /interactions"); });
- Cloudflare Adapter: expects a Request
object from
the Cloudflare Worker fetch event:
ts return await client.listen("/interactions", request);
A promise resolving to the adapter's listen result.
Registers a mentionable select interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers a message context menu interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Adds global middleware that runs on every interaction.
Receives raw APIInteraction payload and response object.
Async functions. See GenericMiddleware for callback parameters.
Registers a modal interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers interaction routes.
InteractionRouter or InteractionRouterCollector instances.
Registers a role select interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers a string select interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Adds global middleware for unknown interactions.
Async Functions executed when no handler matches an interaction. See UnknownMiddleware for callback parameters.
Registers a user context menu interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Registers a user select interaction with its associated middleware.
Async functions. See GenericMiddleware for callback parameters.
Discord HTTPS Interaction Client.
Handles registration of commands, buttons, modals, select menus, context menus, and autocomplete interactions with their associated middleware.
Also exposes a REST client for direct API calls.
Example