detritus

InteractionCommandClientclass

Interaction Command Client, hooks onto a ClusterClient or ShardClient to provide easier command handling Flow is onInteractionCheck -> onCommandCheck

On this page

Interaction Command Client, hooks onto a ClusterClient or ShardClient to provide easier command handling Flow is onInteractionCheck -> onCommandCheck

import { InteractionCommandClient } from 'detritus-client';
EventEmitterEventSpewerInteractionCommandClient

Constructor

Properties

_clientSubscriptions
readonly
Default []
_commandIndex
_syncedScopes
Set<string>
readonly
checkCommands
boolean
Default true
directories
BaseCollection<string, { subdirectories: boolean }>
ran
boolean
Default false
ratelimiter
ratelimits
Default []
strictCommandCheck
boolean
Default true

Accessors

canUpload
boolean
get
manager
ClusterProcessChild | null
get
rest
RestClient | Client
get

Methods

addMultipleIn()

async src/interactioncommandclient.ts:287
addMultipleIn(
  directory: string,
  options?: { isAbsolute?: boolean; subdirectories?: boolean },
): Promise<InteractionCommandClient>
directory
string
options?
{ isAbsolute?: boolean; subdirectories?: boolean }
options.isAbsolute?
boolean
options.subdirectories?
boolean

on()

src/interactioncommandclient.ts:1278
on(event: string | symbol, listener: (...args: any[]) => void): this

Adds 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
//   a

Since v0.1.101

event
string | symbol
listener
(...args: any[]) => void

The callback function

on(event: COMMAND_ERROR, listener: (payload: CommandError) => any): this
on(event: "commandError", listener: (payload: CommandError) => any): this
on(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): this
on(event: "commandFail", listener: (payload: CommandFail) => any): this
on(
  event: COMMAND_PERMISSIONS_FAIL_CLIENT,
  listener: (payload: CommandPermissionsFailClient) => any,
): this
on(
  event: "commandPermissionsFailClient",
  listener: (payload: CommandPermissionsFailClient) => any,
): this
on(
  event: COMMAND_PERMISSIONS_FAIL,
  listener: (payload: CommandPermissionsFail) => any,
): this
on(
  event: "commandPermissionsFail",
  listener: (payload: CommandPermissionsFail) => any,
): this
on(event: COMMAND_RAN, listener: (payload: CommandRan) => any): this
on(event: "commandRan", listener: (payload: CommandRan) => any): this
on(event: COMMAND_RATELIMIT, listener: (payload: CommandRatelimit) => any): this
on(event: "commandRatelimit", listener: (payload: CommandRatelimit) => any): this
on(event: COMMAND_RUN_ERROR, listener: (payload: CommandRunError) => any): this
on(event: "commandRunError", listener: (payload: CommandRunError) => any): this
on(event: KILLED, listener: () => any): this
Overrides EventSpewer.on

once()

src/interactioncommandclient.ts:1299
once(event: string | symbol, listener: (...args: any[]) => void): this

Adds 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
//   a

Since v0.3.0

event
string | symbol
listener
(...args: any[]) => void

The callback function

once(event: COMMAND_ERROR, listener: (payload: CommandError) => any): this
once(event: "commandError", listener: (payload: CommandError) => any): this
once(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): this
once(event: "commandFail", listener: (payload: CommandFail) => any): this
once(
  event: COMMAND_PERMISSIONS_FAIL_CLIENT,
  listener: (payload: CommandPermissionsFailClient) => any,
): this
once(
  event: "commandPermissionsFailClient",
  listener: (payload: CommandPermissionsFailClient) => any,
): this
once(
  event: COMMAND_PERMISSIONS_FAIL,
  listener: (payload: CommandPermissionsFail) => any,
): this
once(
  event: "commandPermissionsFail",
  listener: (payload: CommandPermissionsFail) => any,
): this
once(event: COMMAND_RAN, listener: (payload: CommandRan) => any): this
once(event: "commandRan", listener: (payload: CommandRan) => any): this
once(event: COMMAND_RATELIMIT, listener: (payload: CommandRatelimit) => any): this
once(event: "commandRatelimit", listener: (payload: CommandRatelimit) => any): this
once(event: COMMAND_RUN_ERROR, listener: (payload: CommandRunError) => any): this
once(event: "commandRunError", listener: (payload: CommandRunError) => any): this
once(event: KILLED, listener: () => any): this
Overrides EventSpewer.once

subscribe()

src/interactioncommandclient.ts:1320
subscribe(event: string | symbol, listener: (...args: any[]) => void): EventSubscription
subscribe(
  event: COMMAND_ERROR,
  listener: (payload: CommandError) => any,
): EventSubscription
subscribe(
  event: "commandError",
  listener: (payload: CommandError) => any,
): EventSubscription
subscribe(event: COMMAND_FAIL, listener: (payload: CommandFail) => any): EventSubscription
subscribe(
  event: "commandFail",
  listener: (payload: CommandFail) => any,
): EventSubscription
subscribe(
  event: COMMAND_PERMISSIONS_FAIL_CLIENT,
  listener: (payload: CommandPermissionsFailClient) => any,
): EventSubscription
subscribe(
  event: "commandPermissionsFailClient",
  listener: (payload: CommandPermissionsFailClient) => any,
): EventSubscription
subscribe(
  event: COMMAND_PERMISSIONS_FAIL,
  listener: (payload: CommandPermissionsFail) => any,
): EventSubscription
subscribe(
  event: "commandPermissionsFail",
  listener: (payload: CommandPermissionsFail) => any,
): EventSubscription
subscribe(event: COMMAND_RAN, listener: (payload: CommandRan) => any): EventSubscription
subscribe(event: "commandRan", listener: (payload: CommandRan) => any): EventSubscription
subscribe(
  event: COMMAND_RATELIMIT,
  listener: (payload: CommandRatelimit) => any,
): EventSubscription
subscribe(
  event: "commandRatelimit",
  listener: (payload: CommandRatelimit) => any,
): EventSubscription
subscribe(
  event: COMMAND_RUN_ERROR,
  listener: (payload: CommandRunError) => any,
): EventSubscription
subscribe(
  event: "commandRunError",
  listener: (payload: CommandRunError) => any,
): EventSubscription
subscribe(event: KILLED, listener: () => any): EventSubscription
subscribe(event: "killed", listener: () => any): EventSubscription
Overrides EventSpewer.subscribe