Skip to main content
Module

x/harmony/deploy.ts>SlashClient

An easy to use Discord API Library for Deno.
Latest
class SlashClient
extends HarmonyEventEmitter<InteractionsClientEvents>
import { SlashClient } from "https://deno.land/x/harmony@v2.9.1/deploy.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
commands: ApplicationCommandsManager
componentHandlers: ComponentInteractionHandler[]
enabled: boolean
handlers: ApplicationCommandHandler[]
id: string | (() => string)
modules: ApplicationCommandsModule[]
optional
publicKey: string
readonly
rest: RESTManager
token: string | undefined

Methods

private
_getAutocompleteHandler(i: AutocompleteInteraction): AutocompleteHandler | undefined

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

private
_getCommand(i: ApplicationCommandInteraction): ApplicationCommandHandler | undefined

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

private
_getComponentHandler(i: MessageComponentInteraction): ComponentInteractionHandler | undefined

Get Handler for an component Interaction.

private
_getModalSubmitHandler(i: ModalSubmitInteraction): ComponentInteractionHandler | undefined

Get Handler for an modal submit Interaction.

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

Process an incoming Interaction

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

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

fetchApplication(): Promise<Application>

Fetch Application of the Client (if Token is present)

getHandlers(): ApplicationCommandHandler[]

Get all Handlers. Including Slash Modules

getID(): string
handle(cmd: ApplicationCommandHandler): this

Adds a new Application Command Handler

handle(cmd: string, handler: ApplicationCommandHandlerCallback): this
handle(
cmd: string,
handler: ApplicationCommandHandlerCallback,
type: ApplicationCommandType | keyof ApplicationCommandType,
): this
loadModule(module: ApplicationCommandsModule): InteractionsClient

Load a Slash Module

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.