hoshii / Exports / Client

Client

Represents the main Client class

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Client(token, options)

Create a new client instance

Parameters

NameTypeDescription
tokenstringThe token of the client
optionsClientOptionsThe options for the client

Overrides

TypedEmitter<ClientEvents&gt;.constructor

Defined in

lib/Client.ts:164open in new window

Properties

_gateway

Private _gateway: GatewayHandler

The Gateway handler to handle events

Defined in

lib/Client.ts:112open in new window


options

options: ClientOptions

The options for the client

Defined in

lib/Client.ts:117open in new window


requestHandler

requestHandler: RequestHandler

The request handler to send REST requests

Defined in

lib/Client.ts:122open in new window


servers

servers: TypedCollection<string, RawServer, Server, []>

A collection of cached servers

Defined in

lib/Client.ts:127open in new window


startTime

startTime: number

The time the client started

Defined in

lib/Client.ts:132open in new window


token

token: string

The token of the client

Defined in

lib/Client.ts:137open in new window


user

user: ClientUser

The user of the client

Defined in

lib/Client.ts:142open in new window


users

users: TypedCollection<string, RawUser, User, []>

A collection of cached users

Defined in

lib/Client.ts:147open in new window


util

util: Util

The util class

Defined in

lib/Client.ts:152open in new window


ws

ws: WebSocket

The websocket connection

Defined in

lib/Client.ts:157open in new window


captureRejectionSymbol

Static Readonly captureRejectionSymbol: typeof captureRejectionSymbol

Inherited from

TypedEmitter.captureRejectionSymbol

Defined in

node_modules/@types/node/events.d.ts:328


captureRejections

Static captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Inherited from

TypedEmitter.captureRejections

Defined in

node_modules/@types/node/events.d.ts:333


defaultMaxListeners

Static defaultMaxListeners: number

Inherited from

TypedEmitter.defaultMaxListeners

Defined in

node_modules/@types/node/events.d.ts:334


errorMonitor

Static Readonly errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Inherited from

TypedEmitter.errorMonitor

Defined in

node_modules/@types/node/events.d.ts:327

Accessors

uptime

get uptime(): number

The current uptime of the client

Returns

number

Defined in

lib/Client.ts:207open in new window

Methods

addForumTopicCommentReactionEmote

addForumTopicCommentReactionEmote(channelID, topicID, commentID, emoteID): Promise<void>

Add a reaction emote to a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
commentIDnumberThe ID of the forum topic comment
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:219open in new window


addForumTopicReactionEmote

addForumTopicReactionEmote(channelID, topicID, emoteID): Promise<void>

Add a reaction emote to a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:259open in new window


addListener

addListener<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.addListener

Defined in

lib/utils/TypedEmitter.ts:7open in new window


addReactionEmote

addReactionEmote(channelID, contentID, emoteID): Promise<void>

Add a reaction emote to any supported content type

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
contentIDstringThe ID of the content
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:289open in new window


addServerMemberGroup

addServerMemberGroup(groupID, memberID): Promise<void>

Add a server member to a group

Parameters

NameTypeDescription
groupIDstringThe ID of the group
memberIDstringThe ID of the member

Returns

Promise<void>

Defined in

lib/Client.ts:322open in new window


addServerMemberRole

addServerMemberRole(serverID, memberID, roleID): Promise<void>

Add a role to a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
roleIDnumberThe ID of the role

Returns

Promise<void>

Defined in

lib/Client.ts:347open in new window


awardServerMember

awardServerMember(serverID, memberID, amount): Promise<number>

Award a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
amountOmit<number, "total">The amount to award

Returns

Promise<number>

Defined in

lib/Client.ts:377open in new window


completeListItem

completeListItem(channelID, itemID): Promise<void>

Complete a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
itemIDstringThe ID of the item

Returns

Promise<void>

Defined in

lib/Client.ts:413open in new window


connect

connect(): void

Connect the client to the Guilded gateway

Returns

void

Defined in

lib/Client.ts:431open in new window


createCalendarEvent

createCalendarEvent(channelID, options): Promise<CalendarEvent>

Create a calendar event

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsCalendarEventOptionsThe options to create the event with

Returns

Promise<CalendarEvent>

Defined in

lib/Client.ts:458open in new window


createChannelMessage

createChannelMessage<T>(channelID, options): Promise<ChatMessage<T>>

Create a channel message

Type parameters

NameType
Textends TextChannel<T> = TextChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsMessageCreateOptionsThe message options

Returns

Promise<ChatMessage<T>>

Defined in

lib/Client.ts:489open in new window


createDoc

createDoc(channelID, options): Promise<Doc>

Create a doc

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsDocOptionsThe option to create the doc with

Returns

Promise<Doc>

Defined in

lib/Client.ts:528open in new window


createForumTopic

createForumTopic<T>(channelID, options): Promise<ForumTopic<T>>

Create a forum topic

Type parameters

NameType
Textends ForumChannel<T> = ForumChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsForumTopicOptionsThe forum topic options

Returns

Promise<ForumTopic<T>>

Defined in

lib/Client.ts:556open in new window


createForumTopicComment

createForumTopicComment(channelID, topicID, options): Promise<ForumTopicComment>

Create a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
optionsForumTopicCommentOptionsThe comment options

Returns

Promise<ForumTopicComment>

Defined in

lib/Client.ts:588open in new window


createListItem

createListItem(channelID, options): Promise<ListItem>

Create a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsListItemOptionsThe list item options

Returns

Promise<ListItem>

Defined in

lib/Client.ts:626open in new window


createServerMemberBan

createServerMemberBan(serverID, memberID, reason?): Promise<ServerMemberBan>

Create a server member ban

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe Id othe member
reason?stringThe reason for the ban

Returns

Promise<ServerMemberBan>

Defined in

lib/Client.ts:658open in new window


deleteCalendarEvent

deleteCalendarEvent(channelID, eventID): Promise<void>

Delete a calender event

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event

Returns

Promise<void>

Defined in

lib/Client.ts:693open in new window


deleteCalendarEventRSVP

deleteCalendarEventRSVP(channelID, eventID, memberID): Promise<void>

Delete a calendar event RSVP

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event
memberIDstringThe ID of the member

Returns

Promise<void>

Defined in

lib/Client.ts:718open in new window


deleteChannelMessage

deleteChannelMessage(channelID, messageID): Promise<void>

Delete a channel message

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
messageIDstringThe ID of the message

Returns

Promise<void>

Defined in

lib/Client.ts:747open in new window


deleteDoc

deleteDoc(channelID, docID): Promise<void>

Delete a doc

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
docIDnumberThe ID of the doc

Returns

Promise<void>

Defined in

lib/Client.ts:771open in new window


deleteForumTopic

deleteForumTopic(channelID, topicID): Promise<void>

Delete a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<void>

Defined in

lib/Client.ts:792open in new window


deleteForumTopicComment

deleteForumTopicComment(channelID, topicID, commentID): Promise<void>

Delete a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
commentIDnumberThe ID of the forum comment

Returns

Promise<void>

Defined in

lib/Client.ts:814open in new window


deleteForumTopicCommentReactionEmote

deleteForumTopicCommentReactionEmote(channelID, topicID, commentID, emoteID): Promise<void>

Delete a reaction emote from a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
commentIDnumberThe ID of the forum topic comment
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:849open in new window


deleteForumTopicReactionEmote

deleteForumTopicReactionEmote(channelID, topicID, emoteID): Promise<void>

Delete a reaction emote from a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:889open in new window


deleteListItem

deleteListItem(channelID, itemID): Promise<void>

Delete a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
itemIDstringThe ID of the item

Returns

Promise<void>

Defined in

lib/Client.ts:922open in new window


deleteReactionEmote

deleteReactionEmote(channelID, contentID, emoteID): Promise<void>

Delete a reaction emote

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
contentIDstringThe ID of the content
emoteIDnumberThe ID of the emote

Returns

Promise<void>

Defined in

lib/Client.ts:944open in new window


deleteServerChannel

deleteServerChannel(channelID): Promise<void>

Delete a server channel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel

Returns

Promise<void>

Defined in

lib/Client.ts:976open in new window


deleteServerWebhook

deleteServerWebhook(serverID, webhookID): Promise<void>

Delete a server webhook

Parameters

NameTypeDescription
serverIDstringThe ID of the server
webhookIDstringThe ID of the webhook

Returns

Promise<void>

Defined in

lib/Client.ts:993open in new window


disconnect

disconnect(): void

Disconnect the client from the Guilded gateway

Returns

void

Defined in

lib/Client.ts:1014open in new window


editCalendarEvent

editCalendarEvent(channelID, eventID, options): Promise<CalendarEvent>

Edit a calendar event

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the calendar event
optionsCalendarEventOptionsThe options to edit the calendar event with

Returns

Promise<CalendarEvent>

Defined in

lib/Client.ts:1027open in new window


editCalendarEventRSVP

editCalendarEventRSVP(channelID, eventID, memberID, options): Promise<CalendarEventRSVP>

Edit a calendar event RSVP

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event
memberIDstringThe ID of the member
optionsCalendarEventRSVPEditOptionsThe options to edit the RSVP with

Returns

Promise<CalendarEventRSVP>

Defined in

lib/Client.ts:1065open in new window


editChannelMessage

editChannelMessage<T>(channelID, messageID, options): Promise<ChatMessage<T>>

Edit a channel message

Type parameters

NameType
Textends TextChannel<T> = TextChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
messageIDstringThe ID of the message
optionsMessageEditOptionsThe new message options

Returns

Promise<ChatMessage<T>>

Defined in

lib/Client.ts:1113open in new window


editDoc

editDoc(channelID, docID, options): Promise<Doc>

Edit a doc

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
docIDnumberThe ID of the doc
optionsDocOptionsThe options to edit the doc with

Returns

Promise<Doc>

Defined in

lib/Client.ts:1152open in new window


editForumTopic

editForumTopic<T>(channelID, topicID, options): Promise<ForumTopic<T>>

Edit a forum topic

Type parameters

NameType
Textends ForumChannel<T> = ForumChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
optionsForumTopicOptionsThe options to edit the forum topic with

Returns

Promise<ForumTopic<T>>

Defined in

lib/Client.ts:1189open in new window


editForumTopicComment

editForumTopicComment(channelID, topicID, commentID, options): Promise<ForumTopicComment>

Edit a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
commentIDnumberThe ID of the forum comment
optionsForumTopicCommentOptionsThe comment options

Returns

Promise<ForumTopicComment>

Defined in

lib/Client.ts:1227open in new window


editListItem

editListItem(channelID, itemID, options): Promise<ListItem>

Edit a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
itemIDstringThe ID of the item
optionsListItemOptionsThe options to edit the list item with

Returns

Promise<ListItem>

Defined in

lib/Client.ts:1275open in new window


editServerChannel

editServerChannel<T>(channelID, options): Promise<T>

Edit the server channel

Type parameters

NameType
Textends AnyChannel = AnyChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
optionsServerChannelEditOptionsThe options to edit the channel with

Returns

Promise<T>

Defined in

lib/Client.ts:1311open in new window


editServerMember

editServerMember(serverID, memberID, options): Promise<void>

Edit a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
optionsServerMemberEditOptionsThe options to edit the member with

Returns

Promise<void>

Defined in

lib/Client.ts:1351open in new window


editServerWebhook

editServerWebhook(serverID, webhookID, options): Promise<Webhook>

Edit a server webhook

Parameters

NameTypeDescription
serverIDstringThe ID of the server
webhookIDstringThe ID of the webhook
optionsWebhookEditOptionsThe options to edit the webhook with

Returns

Promise<Webhook>

Defined in

lib/Client.ts:1377open in new window


emit

emit<K>(eventName, ...args): boolean

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventNameK
...argsClientEvents[K]

Returns

boolean

Inherited from

TypedEmitter.emit

Defined in

lib/utils/TypedEmitter.ts:11open in new window

emit<K>(eventName, ...args): boolean

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventNameK
...argsClientEvents[K]

Returns

boolean

Inherited from

TypedEmitter.emit

Defined in

lib/utils/TypedEmitter.ts:45open in new window


eventNames

eventNames(): (string | symbol)[]

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

const EventEmitter = require('events');
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});

const sym = Symbol('symbol');
myEE.on(sym, () => {});

console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]

Since

v6.0.0

Returns

(string | symbol)[]

Inherited from

TypedEmitter.eventNames

Defined in

node_modules/@types/node/events.d.ts:669


getCalendarEvent

getCalendarEvent(channelID, eventID): Promise<CalendarEvent>

Get a calendar event

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event

Returns

Promise<CalendarEvent>

Defined in

lib/Client.ts:1417open in new window


getCalendarEventRSVP

getCalendarEventRSVP(channelID, eventID, memberID): Promise<CalendarEventRSVP>

Get a calendar event RSVP

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event
memberIDstringThe ID of the member

Returns

Promise<CalendarEventRSVP>

Defined in

lib/Client.ts:1444open in new window


getCalendarEventRSVPs

getCalendarEventRSVPs(channelID, eventID): Promise<CalendarEventRSVP[]>

Get calendar event RSVPs

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
eventIDnumberThe ID of the event

Returns

Promise<CalendarEventRSVP[]>

Defined in

lib/Client.ts:1489open in new window


getCalendarEvents

getCalendarEvents(channelID, filter): Promise<CalendarEvent[]>

Get calendar events

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
filterCalendarEventFilterThe options to filter the output

Returns

Promise<CalendarEvent[]>

Defined in

lib/Client.ts:1527open in new window


getChannelMessage

getChannelMessage<T>(channelID, messageID): Promise<ChatMessage<T>>

Get a channel message

Type parameters

NameType
Textends TextChannel<T> = TextChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
messageIDstringThe ID of the message

Returns

Promise<ChatMessage<T>>

Defined in

lib/Client.ts:1568open in new window


getChannelMessages

getChannelMessages<T>(channelID, filter): Promise<ChatMessage<T>[]>

Get channel messages

Type parameters

NameType
Textends TextChannel<T> = TextChannel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
filterChannelMessagesFilterThe options to filter the output

Returns

Promise<ChatMessage<T>[]>

Defined in

lib/Client.ts:1602open in new window


getDoc

getDoc(channelID, docID): Promise<Doc>

Get a doc

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
docIDnumberThe ID of the doc

Returns

Promise<Doc>

Defined in

lib/Client.ts:1647open in new window


getDocs

getDocs(channelID, filter): Promise<Doc[]>

Get docs

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
filterDocsFilterThe options to filter the output

Returns

Promise<Doc[]>

Defined in

lib/Client.ts:1677open in new window


getForumTopic

getForumTopic(channelID, topicID): Promise<ForumTopic<ForumChannel>>

Get a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<ForumTopic<ForumChannel>>

Defined in

lib/Client.ts:1713open in new window


getForumTopicComment

getForumTopicComment(channelID, topicID, commentID): Promise<ForumTopicComment>

Get a forum topic comment

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic
commentIDnumberThe ID of the forum topic comment

Returns

Promise<ForumTopicComment>

Defined in

lib/Client.ts:1740open in new window


getForumTopicComments

getForumTopicComments(channelID, topicID): Promise<ForumTopicComment[]>

Get forum topic comments

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the topic

Returns

Promise<ForumTopicComment[]>

Defined in

lib/Client.ts:1777open in new window


getForumTopics

getForumTopics(channelID, filter): Promise<ForumTopic<ForumChannel>[]>

Get forum topics

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
filterForumTopicsFilterThe options to filter the output

Returns

Promise<ForumTopic<ForumChannel>[]>

Defined in

lib/Client.ts:1807open in new window


getListItem

getListItem(channelID, itemID): Promise<ListItem>

Get a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
itemIDstringThe ID of the list item

Returns

Promise<ListItem>

Defined in

lib/Client.ts:1841open in new window


getListItems

getListItems(channelID): Promise<ListItem[]>

Get list items

Parameters

NameTypeDescription
channelIDstringThe ID of the channel

Returns

Promise<ListItem[]>

Defined in

lib/Client.ts:1863open in new window


getMaxListeners

getMaxListeners(): number

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

Since

v1.0.0

Returns

number

Inherited from

TypedEmitter.getMaxListeners

Defined in

node_modules/@types/node/events.d.ts:526


getServer

getServer(serverID): Promise<Server>

Get a server

Parameters

NameTypeDescription
serverIDstringThe ID of the server

Returns

Promise<Server>

Defined in

lib/Client.ts:1883open in new window


getServerChannel

getServerChannel(channelID): Promise<AnyChannel>

Get a server channel

Parameters

NameTypeDescription
channelIDstringThe ID of the channel

Returns

Promise<AnyChannel>

Defined in

lib/Client.ts:1901open in new window


getServerMember

getServerMember(serverID, memberID): Promise<ServerMember>

Get a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member

Returns

Promise<ServerMember>

Defined in

lib/Client.ts:1920open in new window


getServerMemberSocialLink(serverID, memberID, socialMediaName): Promise<SocialLink>

Get a social link of a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
socialMediaNamestringThe name of the social media

Returns

Promise<SocialLink>

Defined in

lib/Client.ts:1971open in new window


getServerMembers

getServerMembers(serverID): Promise<ServerMember[]>

Get server members

Parameters

NameTypeDescription
serverIDstringThe ID of the server

Returns

Promise<ServerMember[]>

Defined in

lib/Client.ts:1947open in new window


getServerWebhooks

getServerWebhooks(serverID, filter): Promise<Webhook[]>

Get server webhooks

Parameters

NameTypeDescription
serverIDstringThe ID of the server
filterWebhookFilterThe options to filter the output

Returns

Promise<Webhook[]>

Defined in

lib/Client.ts:2010open in new window


getUser

getUser(userID): Promise<User>

Get a user

Parameters

NameTypeDescription
userIDstringThe ID of the user

Returns

Promise<User>

Defined in

lib/Client.ts:2040open in new window


listenerCount

listenerCount(eventName): number

Parameters

NameType
eventNamekeyof ClientEvents

Returns

number

Inherited from

TypedEmitter.listenerCount

Defined in

lib/utils/TypedEmitter.ts:12open in new window


listeners

listeners(eventName): Function[]

Parameters

NameType
eventNamekeyof ClientEvents

Returns

Function[]

Inherited from

TypedEmitter.listeners

Defined in

lib/utils/TypedEmitter.ts:13open in new window


lockForumTopic

lockForumTopic(channelID, topicID): Promise<void>

Lock a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<void>

Defined in

lib/Client.ts:2059open in new window


off

off<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.off

Defined in

lib/utils/TypedEmitter.ts:14open in new window


on

on<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.on

Defined in

lib/utils/TypedEmitter.ts:18open in new window


once

once<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.once

Defined in

lib/utils/TypedEmitter.ts:22open in new window


pinForumTopic

pinForumTopic(channelID, topicID): Promise<void>

Pin a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<void>

Defined in

lib/Client.ts:2080open in new window


prependListener

prependListener<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.prependListener

Defined in

lib/utils/TypedEmitter.ts:26open in new window


prependOnceListener

prependOnceListener<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.prependOnceListener

Defined in

lib/utils/TypedEmitter.ts:30open in new window


rawListeners

rawListeners(eventName): Function[]

Parameters

NameType
eventNamekeyof ClientEvents

Returns

Function[]

Inherited from

TypedEmitter.rawListeners

Defined in

lib/utils/TypedEmitter.ts:34open in new window


removeAllListeners

removeAllListeners(event?): Client

Parameters

NameType
event?keyof ClientEvents

Returns

Client

Inherited from

TypedEmitter.removeAllListeners

Defined in

lib/utils/TypedEmitter.ts:35open in new window


removeListener

removeListener<K>(event, listener): Client

Type parameters

NameType
Kextends keyof ClientEvents

Parameters

NameType
eventK
listener(...args: ClientEvents[K]) => void

Returns

Client

Inherited from

TypedEmitter.removeListener

Defined in

lib/utils/TypedEmitter.ts:36open in new window


removeServerMember

removeServerMember(serverID, memberID): Promise<void>

Remove a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member

Returns

Promise<void>

Defined in

lib/Client.ts:2101open in new window


removeServerMemberBan

removeServerMemberBan(serverID, memberID): Promise<void>

Remove a server member ban

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member

Returns

Promise<void>

Defined in

lib/Client.ts:2117open in new window


removeServerMemberGroup

removeServerMemberGroup(groupID, memberID): Promise<void>

Remove a server member from a group

Parameters

NameTypeDescription
groupIDstringThe ID of the group
memberIDstringThe Id of the member

Returns

Promise<void>

Defined in

lib/Client.ts:2141open in new window


removeServerMemberRole

removeServerMemberRole(serverID, memberID, roleID): Promise<void>

Remove a role from a server member

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
roleIDnumberThe ID of the role

Returns

Promise<void>

Defined in

lib/Client.ts:2166open in new window


setMaxListeners

setMaxListeners(n): Client

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set toInfinity (or 0) to indicate an unlimited number of listeners.

Returns a reference to the EventEmitter, so that calls can be chained.

Since

v0.3.5

Parameters

NameType
nnumber

Returns

Client

Inherited from

TypedEmitter.setMaxListeners

Defined in

node_modules/@types/node/events.d.ts:520


setServerMemberXP

setServerMemberXP(serverID, memberID, total): Promise<number>

Set a server member XP

Parameters

NameTypeDescription
serverIDstringThe ID of the server
memberIDstringThe ID of the member
totalOmit<number, "amount">The total XP

Returns

Promise<number>

Defined in

lib/Client.ts:2196open in new window


uncompleteListItem

uncompleteListItem(channelID, itemID): Promise<void>

Uncomplete a list item

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
itemIDstringThe ID of the item

Returns

Promise<void>

Defined in

lib/Client.ts:2232open in new window


unlockForumTopic

unlockForumTopic(channelID, topicID): Promise<void>

Unlock a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<void>

Defined in

lib/Client.ts:2256open in new window


unpinForumTopic

unpinForumTopic(channelID, topicID): Promise<void>

Unpin a forum topic

Parameters

NameTypeDescription
channelIDstringThe ID of the channel
topicIDnumberThe ID of the forum topic

Returns

Promise<void>

Defined in

lib/Client.ts:2277open in new window


getEventListeners

Static getEventListeners(emitter, name): Function[]

Returns a copy of the array of listeners for the event named eventName.

For EventEmitters this behaves exactly the same as calling .listeners on the emitter.

For EventTargets this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.

const { getEventListeners, EventEmitter } = require('events');

{
  const ee = new EventEmitter();
  const listener = () => console.log('Events are fun');
  ee.on('foo', listener);
  getEventListeners(ee, 'foo'); // [listener]
}
{
  const et = new EventTarget();
  const listener = () => console.log('Events are fun');
  et.addEventListener('foo', listener);
  getEventListeners(et, 'foo'); // [listener]
}

Since

v15.2.0, v14.17.0

Parameters

NameType
emitterEventEmitter | _DOMEventTarget
namestring | symbol

Returns

Function[]

Inherited from

TypedEmitter.getEventListeners

Defined in

node_modules/@types/node/events.d.ts:299


listenerCount

Static listenerCount(emitter, eventName): number

A class method that returns the number of listeners for the given eventNameregistered on the given emitter.

const { EventEmitter, listenerCount } = require('events');
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2

Since

v0.9.12

Deprecated

Since v3.2.0 - Use listenerCount instead.

Parameters

NameTypeDescription
emitterEventEmitterThe emitter to query
eventNamestring | symbolThe event name

Returns

number

Inherited from

TypedEmitter.listenerCount

Defined in

node_modules/@types/node/events.d.ts:271


on

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
})();

Returns an AsyncIterator that iterates eventName events. It will throw if the EventEmitter emits 'error'. It removes all listeners when exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

An AbortSignal can be used to cancel waiting on events:

const { on, EventEmitter } = require('events');
const ac = new AbortController();

(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', { signal: ac.signal })) {
    // 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
})();

process.nextTick(() => ac.abort());

Since

v13.6.0, v12.16.0

Parameters

NameTypeDescription
emitterEventEmitter-
eventNamestringThe name of the event being listened for
options?StaticEventEmitterOptions-

Returns

AsyncIterableIterator<any>

that iterates eventName events emitted by the emitter

Inherited from

TypedEmitter.on

Defined in

node_modules/@types/node/events.d.ts:254


once

Static once(emitter, eventName, options?): Promise<any[]>

Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

This method is intentionally generic and works with the web platform EventTargetopen in new window interface, which has no special'error' event semantics and does not listen to the 'error' event.

const { once, EventEmitter } = require('events');

async function run() {
  const ee = new EventEmitter();

  process.nextTick(() => {
    ee.emit('myevent', 42);
  });

  const [value] = await once(ee, 'myevent');
  console.log(value);

  const err = new Error('kaboom');
  process.nextTick(() => {
    ee.emit('error', err);
  });

  try {
    await once(ee, 'myevent');
  } catch (err) {
    console.log('error happened', err);
  }
}

run();

The special handling of the 'error' event is only used when events.once()is used to wait for another event. If events.once() is used to wait for the 'error' event itself, then it is treated as any other kind of event without special handling:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();

once(ee, 'error')
  .then(([err]) => console.log('ok', err.message))
  .catch((err) => console.log('error', err.message));

ee.emit('error', new Error('boom'));

// Prints: ok boom

An AbortSignal can be used to cancel waiting for the event:

const { EventEmitter, once } = require('events');

const ee = new EventEmitter();
const ac = new AbortController();

async function foo(emitter, event, signal) {
  try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
  } catch (error) {
    if (error.name === 'AbortError') {
      console.error('Waiting for the event was canceled!');
    } else {
      console.error('There was an error', error.message);
    }
  }
}

foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!

Since

v11.13.0, v10.16.0

Parameters

NameType
emitter_NodeEventTarget
eventNamestring | symbol
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

TypedEmitter.once

Defined in

node_modules/@types/node/events.d.ts:194

Static once(emitter, eventName, options?): Promise<any[]>

Parameters

NameType
emitter_DOMEventTarget
eventNamestring
options?StaticEventEmitterOptions

Returns

Promise<any[]>

Inherited from

TypedEmitter.once

Defined in

node_modules/@types/node/events.d.ts:195


setMaxListeners

Static setMaxListeners(n?, ...eventTargets): void

const {
  setMaxListeners,
  EventEmitter
} = require('events');

const target = new EventTarget();
const emitter = new EventEmitter();

setMaxListeners(5, target, emitter);

Since

v15.4.0

Parameters

NameTypeDescription
n?numberA non-negative number. The maximum number of listeners per EventTarget event.
...eventTargets(EventEmitter | _DOMEventTarget)[]-

Returns

void

Inherited from

TypedEmitter.setMaxListeners

Defined in

node_modules/@types/node/events.d.ts:317

Last Updated:
Contributors: Reinhardt