SparkClient extends Client<Ready>
new SparkClient(options)
Parameter | Type | Optional | Description |
---|---|---|---|
options | SparkClientOptions | ❌ | - |
Properties
public application: If<Ready, ClientApplication, null>
public channels: ChannelManager
public directories: Readonly<SparkClientDirectories>
The directories used for the handler.
public guilds: GuildManager
private logLevel: LogLevel
The log level used by the logger.
public logger: Logger
The logger to be used by the handler. Logger implemented by
public options: Omit<ClientOptions, 'intents'> & { intents: IntentsBitField }
public prefix: string
The prefix used for text commands. Defaults to '!'
public readyTimestamp: If<Ready, number, null>
public rest: REST
public shard: null | ShardClientUtil
public sweepers: Sweepers
public token: If<Ready, string, null | string>
public user: If<Ready, ClientUser, null>
public users: UserManager
public voice: ClientVoiceManager
public ws: WebSocketManager
public static captureRejectionSymbol: (typeof captureRejectionSymbol)
public static captureRejections: boolean
Sets or gets the default captureRejection value for all emitters.
public static defaultMaxListeners: number
public static errorMonitor: (typeof errorMonitor)
This symbol shall be used to install a listener for only monitoring
public _censoredToken: null | string
public emojis: BaseGuildEmojiManager
public readyAt: If<Ready, Date, null>
public uptime: If<Ready, number, null>
Methods
public addListener(eventName, listener): SparkClient<Ready>
Alias for
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | - |
listener | (args: Array<any>) => void | ❌ | - |
public destroy(): void
public emit(event, args): boolean
Parameter | Type | Optional | Description |
---|---|---|---|
event | K | ❌ | - |
args | ClientEvents[K] | ❌ | - |
public eventNames(): Array<string | symbol>
Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or
public fetchGuildPreview(guild): Promise<GuildPreview>
Parameter | Type | Optional | Description |
---|---|---|---|
guild | GuildResolvable | ❌ | - |
public fetchGuildTemplate(template): Promise<GuildTemplate>
Parameter | Type | Optional | Description |
---|---|---|---|
template | string | ❌ | - |
public fetchGuildWidget(guild): Promise<Widget>
Parameter | Type | Optional | Description |
---|---|---|---|
guild | GuildResolvable | ❌ | - |
public fetchInvite(invite, options?): Promise<Invite>
Parameter | Type | Optional | Description |
---|---|---|---|
invite | string | ❌ | - |
options | ClientFetchInviteOptions | ✅ | - |
public fetchPremiumStickerPacks(): Promise<Collection<string, StickerPack>>
public fetchSticker(id): Promise<Sticker>
Parameter | Type | Optional | Description |
---|---|---|---|
id | string | ❌ | - |
public fetchVoiceRegions(): Promise<Collection<string, VoiceRegion>>
public fetchWebhook(id, token?): Promise<Webhook>
Parameter | Type | Optional | Description |
---|---|---|---|
id | string | ❌ | - |
token | string | ✅ | - |
public generateInvite(options?): string
Parameter | Type | Optional | Description |
---|---|---|---|
options | InviteGenerationOptions | ✅ | - |
public getMaxListeners(): number
Returns the current max listener value for the
public isReady(): this is Client<true>
public listenerCount(eventName): number
Returns the number of listeners listening to the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | The name of the event being listened for |
public listeners(eventName): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | - |
public login(token): Promise<string>
Registers the handler and logs into the bot. Usage:
Parameter | Type | Optional | Description |
---|---|---|---|
token | string | ❌ | - |
public off(event, listener): SparkClient<Ready>
Parameter | Type | Optional | Description |
---|---|---|---|
event | K | ❌ | - |
listener | (args: ClientEvents[K]) => Awaitable<void> | ❌ | - |
public on(event, listener): SparkClient<Ready>
Parameter | Type | Optional | Description |
---|---|---|---|
event | K | ❌ | - |
listener | (args: ClientEvents[K]) => Awaitable<void> | ❌ | - |
public once(event, listener): SparkClient<Ready>
Parameter | Type | Optional | Description |
---|---|---|---|
event | K | ❌ | - |
listener | (args: ClientEvents[K]) => Awaitable<void> | ❌ | - |
public prependListener(eventName, listener): SparkClient<Ready>
Adds the
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | The name of the event. |
listener | (args: Array<any>) => void | ❌ | The callback function |
public prependOnceListener(eventName, listener): SparkClient<Ready>
Adds a one-time
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | The name of the event. |
listener | (args: Array<any>) => void | ❌ | The callback function |
public rawListeners(eventName): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | - |
public removeAllListeners(event?): SparkClient<Ready>
Parameter | Type | Optional | Description |
---|---|---|---|
event | K | ✅ | - |
public removeListener(eventName, listener): SparkClient<Ready>
Removes the specified
Parameter | Type | Optional | Description |
---|---|---|---|
eventName | string | symbol | ❌ | - |
listener | (args: Array<any>) => void | ❌ | - |
public setMaxListeners(n): SparkClient<Ready>
By default
Parameter | Type | Optional | Description |
---|---|---|---|
n | number | ❌ | - |
public toJSON(): unknown
public static getEventListeners(emitter, name): Array<Function>
Returns a copy of the array of listeners for the event named
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | _DOMEventTarget | ❌ | - |
name | string | symbol | ❌ | - |
public static listenerCount(emitter, eventName): number
A class method that returns the number of listeners for the given
- ⚠️ Deprecated
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | ❌ | The emitter to query |
eventName | string | symbol | ❌ | The event name |
public static on(emitter, eventName, options?): AsyncIterableIterator<any>
const { on, EventEmitter } = require('events');
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | EventEmitter | ❌ | - |
eventName | string | ❌ | The name of the event being listened for |
options | StaticEventEmitterOptions | ✅ | - |
public static once(emitter, eventName, options?): Promise<Array<any>>
Creates a
Parameter | Type | Optional | Description |
---|---|---|---|
emitter | _NodeEventTarget | ❌ | - |
eventName | string | symbol | ❌ | - |
options | StaticEventEmitterOptions | ✅ | - |
public static setMaxListeners(n?, eventTargets): void
const {
setMaxListeners,
EventEmitter
} = require('events');
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
Parameter | Type | Optional | Description |
---|---|---|---|
n | number | ✅ | A non-negative number. The maximum number of listeners per |
eventTargets | Array<EventEmitter | _DOMEventTarget> | ❌ | - |