new InteractionCommandClient
src/interactioncommandclient.ts:128new InteractionCommandClient(
token: string | ClusterClient | CommandClient | ShardClient,
options?: InteractionCommandClientOptions,
)Interaction Command Client, hooks onto a ClusterClient or ShardClient to provide easier command handling Flow is onInteractionCheck -> onCommandCheck
Interaction Command Client, hooks onto a ClusterClient or ShardClient to provide easier command handling Flow is onInteractionCheck -> onCommandCheck
import { InteractionCommandClient } from 'detritus-client';new InteractionCommandClient(
token: string | ClusterClient | CommandClient | ShardClient,
options?: InteractionCommandClientOptions,
)add(
options: InteractionCommandClientAddOptions | InteractionCommand<ParsedArgs>,
run?: CommandCallbackRun,
): thisaddMultiple(
commands?: (InteractionCommandOptions | InteractionCommand<ParsedArgs>)[],
): thisaddMultipleIn(
directory: string,
options?: { isAbsolute?: boolean; subdirectories?: boolean },
): Promise<InteractionCommandClient>applyApplicationCommandsPlan(
commands: BaseCollection<string, ApplicationCommand>,
plan: ApplicationCommandsPlan,
guildId?: string,
): Promise<BaseCollection<string, ApplicationCommand>>checkAndUploadCommands(force?: boolean): Promise<void>checkApplicationCommands(guildId?: string): Promise<boolean>clear(): voidclearSubscriptions(): voidcreateApplicationCommandPayload(command: InteractionCommand): { toJSON: () => object }createApplicationCommandsFromRaw(data: any[]): BaseCollection<string, ApplicationCommand>fetchApplicationCommands(
guildId?: string,
): Promise<BaseCollection<string, ApplicationCommand>>fillCommandIds(
commands: BaseCollection<string, ApplicationCommand>,
guildId?: string,
): voidfindCommand(
data: InteractionDataApplicationCommand,
interactionGuildId?: string | null,
): InteractionCommand<ParsedArgs> | undefinedgetCommandIndex(guildId: string): InteractionCommandIndex | nullhandleApplicationCommand(event: InteractionCreate): Promise<void>handleApplicationCommandAutoComplete(event: InteractionCreate): Promise<void>handleApplicationCommandContext(
context: InteractionContext,
data: InteractionDataApplicationCommand,
): Promise<void>handleInteractionCreate(event: InteractionCreate): Promise<void>kill(): voidon(event: string | symbol, listener: (...args: any[]) => void): thisAdds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
server.on('connection', (stream) => {
console.log('someone connected!');
});Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// aThe callback function
on(event: COMMAND_ERROR, listener: (payload: CommandError) => any): thison(event: "commandError", listener: (payload: CommandError) => any): thison(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): thison(event: "commandFail", listener: (payload: CommandFail) => any): thison(
event: COMMAND_PERMISSIONS_FAIL_CLIENT,
listener: (payload: CommandPermissionsFailClient) => any,
): thison(
event: "commandPermissionsFailClient",
listener: (payload: CommandPermissionsFailClient) => any,
): thison(
event: COMMAND_PERMISSIONS_FAIL,
listener: (payload: CommandPermissionsFail) => any,
): thison(
event: "commandPermissionsFail",
listener: (payload: CommandPermissionsFail) => any,
): thison(event: COMMAND_RAN, listener: (payload: CommandRan) => any): thison(event: "commandRan", listener: (payload: CommandRan) => any): thison(event: COMMAND_RATELIMIT, listener: (payload: CommandRatelimit) => any): thison(event: "commandRatelimit", listener: (payload: CommandRatelimit) => any): thison(event: COMMAND_RUN_ERROR, listener: (payload: CommandRunError) => any): thison(event: "commandRunError", listener: (payload: CommandRunError) => any): thison(event: KILLED, listener: () => any): thisonce(event: string | symbol, listener: (...args: any[]) => void): thisAdds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// aThe callback function
once(event: COMMAND_ERROR, listener: (payload: CommandError) => any): thisonce(event: "commandError", listener: (payload: CommandError) => any): thisonce(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): thisonce(event: "commandFail", listener: (payload: CommandFail) => any): thisonce(
event: COMMAND_PERMISSIONS_FAIL_CLIENT,
listener: (payload: CommandPermissionsFailClient) => any,
): thisonce(
event: "commandPermissionsFailClient",
listener: (payload: CommandPermissionsFailClient) => any,
): thisonce(
event: COMMAND_PERMISSIONS_FAIL,
listener: (payload: CommandPermissionsFail) => any,
): thisonce(
event: "commandPermissionsFail",
listener: (payload: CommandPermissionsFail) => any,
): thisonce(event: COMMAND_RAN, listener: (payload: CommandRan) => any): thisonce(event: "commandRan", listener: (payload: CommandRan) => any): thisonce(event: COMMAND_RATELIMIT, listener: (payload: CommandRatelimit) => any): thisonce(event: "commandRatelimit", listener: (payload: CommandRatelimit) => any): thisonce(event: COMMAND_RUN_ERROR, listener: (payload: CommandRunError) => any): thisonce(event: "commandRunError", listener: (payload: CommandRunError) => any): thisonce(event: KILLED, listener: () => any): thisonCommandCancel(context: InteractionContext, command: InteractionCommand): unknownonCommandCheck(
context: InteractionContext,
command: InteractionCommand,
): boolean | Promise<boolean>onInteractionCancel(context: InteractionContext): unknownonInteractionCheck(context: InteractionContext): boolean | Promise<boolean>parseArgs(
context: InteractionContext,
data: InteractionDataApplicationCommand,
): Promise<[ParsedArgs, ParsedErrors | null]>parseArgsFromContextMenu(
data: InteractionDataApplicationCommand,
): Promise<[ParsedArgs, null]>parseArgsFromOptions(
context: InteractionContext,
commandOptions?: BaseCollection<string, InteractionCommandOption<ParsedArgs>>,
options?: BaseCollection<string, InteractionDataApplicationCommandOption>,
resolved?: InteractionDataApplicationCommandResolved,
): Promise<[ParsedArgs, ParsedErrors | null]>parseDefaultArgsFromOptions(
context: InteractionContext,
commandOptions: BaseCollection<string, InteractionCommandOption<ParsedArgs>>,
args?: ParsedArgs,
errors?: ParsedErrors,
): Promise<boolean>planApplicationCommands(
commands: BaseCollection<string, ApplicationCommand>,
guildId?: string,
): ApplicationCommandsPlanresetCommands(): Promise<void>run(options?: InteractionCommandClientRunOptions): Promise<ClusterClient | ShardClient>setSubscriptions(): voidsubscribe(event: string | symbol, listener: (...args: any[]) => void): EventSubscriptionsubscribe(
event: COMMAND_ERROR,
listener: (payload: CommandError) => any,
): EventSubscriptionsubscribe(
event: "commandError",
listener: (payload: CommandError) => any,
): EventSubscriptionsubscribe(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): EventSubscriptionsubscribe(
event: "commandFail",
listener: (payload: CommandFail) => any,
): EventSubscriptionsubscribe(
event: COMMAND_PERMISSIONS_FAIL_CLIENT,
listener: (payload: CommandPermissionsFailClient) => any,
): EventSubscriptionsubscribe(
event: "commandPermissionsFailClient",
listener: (payload: CommandPermissionsFailClient) => any,
): EventSubscriptionsubscribe(
event: COMMAND_PERMISSIONS_FAIL,
listener: (payload: CommandPermissionsFail) => any,
): EventSubscriptionsubscribe(
event: "commandPermissionsFail",
listener: (payload: CommandPermissionsFail) => any,
): EventSubscriptionsubscribe(event: COMMAND_RAN, listener: (payload: CommandRan) => any): EventSubscriptionsubscribe(event: "commandRan", listener: (payload: CommandRan) => any): EventSubscriptionsubscribe(
event: COMMAND_RATELIMIT,
listener: (payload: CommandRatelimit) => any,
): EventSubscriptionsubscribe(
event: "commandRatelimit",
listener: (payload: CommandRatelimit) => any,
): EventSubscriptionsubscribe(
event: COMMAND_RUN_ERROR,
listener: (payload: CommandRunError) => any,
): EventSubscriptionsubscribe(
event: "commandRunError",
listener: (payload: CommandRunError) => any,
): EventSubscriptionsubscribe(event: KILLED, listener: () => any): EventSubscriptionsubscribe(event: "killed", listener: () => any): EventSubscriptionuploadApplicationCommands(
guildId?: string,
): Promise<BaseCollection<string, ApplicationCommand>>validateCommands(
commands: BaseCollection<string, ApplicationCommand>,
guildId?: string,
): booleanvalidateCommandsFromRaw(data: any[]): boolean