Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/harmony/src/interactions/client.ts>SlashClient

An easy to use Discord API Library for Deno.
Go to Latest
import { SlashClient } from "https://deno.land/x/harmony@v2.8.0/src/interactions/client.ts";

Slash Client represents an Interactions Client which can be used without Harmony Client.

Constructors

new
SlashClient(options: SlashOptions)

Properties

autocompleteHandlers: AutocompleteHandler[]
optional
client: Client
enabled: boolean
id: string | (() => string)
optional
publicKey: string
readonly
rest: RESTManager
token: string | undefined

Methods

Get Handler for an autocomplete Interaction. Supports nested sub commands and sub command groups.

Get Handler for an Interaction. Supports nested sub commands and sub command groups.

_process(interaction: Interaction | ApplicationCommandInteraction): Promise<void>

Process an incoming Interaction

autocomplete(
cmd: string,
option: string,
): this

Add a handler for autocompletions (for application command options).

Fetch Application of the Client (if Token is present)

Get all Handlers. Including Slash Modules

getID(): string

Adds a new Application Command Handler

handle(cmd: string, handler: ApplicationCommandHandlerCallback): this
handle(
cmd: string,
type: ApplicationCommandType | keyof ApplicationCommandType,
): this
verifyFetchEvent(unnamed 0: { respondWith: CallableFunction; request: Request; }): Promise<false | Interaction>

Verify FetchEvent (for Service Worker usage) and return Interaction if valid

verifyKey(
rawBody: string | Uint8Array,
signature: string | Uint8Array,
timestamp: string | Uint8Array,
): boolean

Verify HTTP based Interaction

verifyOakRequest<T extends { request: { headers: Headers; hasBody: boolean; body: () => { value: Promise<Uint8Array>; }; }; }>(ctx: T): Promise<boolean>

Method to verify Request from Oak server "Context".

verifyOpineMiddleware<Req extends { headers: Headers; body: Deno.Reader; }, Res extends { setStatus: (code: number) => Res; end: () => Res; }>(
req: Req,
res: Res,
next: CallableFunction,
): Promise<boolean>

Middleware to verify request in Opine framework.

verifyOpineRequest<T extends { headers: Headers; body: Deno.Reader; }>(req: T): Promise<boolean>
verifyServerRequest(req: { headers: Headers; method: string; body: Deno.Reader | Uint8Array; respond: (options: { status?: number; headers?: Headers; body?: BodyInit; }) => Promise<void>; }): Promise<false | Interaction>

Verify Deno Std HTTP Server Request and return Interaction.

Data present in Interaction returned by this method is very different from actual typings as there is no real Client behind the scenes to cache things.