Client
Represents the main Client class
Hierarchy
TypedEmitter
<ClientEvents
>↳
Client
Table of contents
Constructors
Properties
- _gateway
- options
- requestHandler
- servers
- startTime
- token
- user
- users
- util
- ws
- captureRejectionSymbol
- captureRejections
- defaultMaxListeners
- errorMonitor
Accessors
Methods
- addForumTopicCommentReactionEmote
- addForumTopicReactionEmote
- addListener
- addReactionEmote
- addServerMemberGroup
- addServerMemberRole
- awardServerMember
- completeListItem
- connect
- createCalendarEvent
- createChannelMessage
- createDoc
- createForumTopic
- createForumTopicComment
- createListItem
- createServerMemberBan
- deleteCalendarEvent
- deleteCalendarEventRSVP
- deleteChannelMessage
- deleteDoc
- deleteForumTopic
- deleteForumTopicComment
- deleteForumTopicCommentReactionEmote
- deleteForumTopicReactionEmote
- deleteListItem
- deleteReactionEmote
- deleteServerChannel
- deleteServerWebhook
- disconnect
- editCalendarEvent
- editCalendarEventRSVP
- editChannelMessage
- editDoc
- editForumTopic
- editForumTopicComment
- editListItem
- editServerChannel
- editServerMember
- editServerWebhook
- emit
- eventNames
- getCalendarEvent
- getCalendarEventRSVP
- getCalendarEventRSVPs
- getCalendarEvents
- getChannelMessage
- getChannelMessages
- getDoc
- getDocs
- getForumTopic
- getForumTopicComment
- getForumTopicComments
- getForumTopics
- getListItem
- getListItems
- getMaxListeners
- getServer
- getServerChannel
- getServerMember
- getServerMemberSocialLink
- getServerMembers
- getServerWebhooks
- getUser
- listenerCount
- listeners
- lockForumTopic
- off
- on
- once
- pinForumTopic
- prependListener
- prependOnceListener
- rawListeners
- removeAllListeners
- removeListener
- removeServerMember
- removeServerMemberBan
- removeServerMemberGroup
- removeServerMemberRole
- setMaxListeners
- setServerMemberXP
- uncompleteListItem
- unlockForumTopic
- unpinForumTopic
- getEventListeners
- listenerCount
- on
- once
- setMaxListeners
Constructors
constructor
• new Client(token
, options
)
Create a new client instance
Parameters
Name | Type | Description |
---|---|---|
token | string | The token of the client |
options | ClientOptions | The options for the client |
Overrides
TypedEmitter<ClientEvents>.constructor
Defined in
Properties
_gateway
• Private
_gateway: GatewayHandler
The Gateway handler to handle events
Defined in
options
• options: ClientOptions
The options for the client
Defined in
requestHandler
• requestHandler: RequestHandler
The request handler to send REST requests
Defined in
servers
• servers: TypedCollection
<string
, RawServer
, Server
, []>
A collection of cached servers
Defined in
startTime
• startTime: number
The time the client started
Defined in
token
• token: string
The token of the client
Defined in
user
• user: ClientUser
The user of the client
Defined in
users
• users: TypedCollection
<string
, RawUser
, User
, []>
A collection of cached users
Defined in
util
• util: Util
The util class
Defined in
ws
• ws: WebSocket
The websocket connection
Defined in
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
Methods
addForumTopicCommentReactionEmote
▸ addForumTopicCommentReactionEmote(channelID
, topicID
, commentID
, emoteID
): Promise
<void
>
Add a reaction emote to a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
commentID | number | The ID of the forum topic comment |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
addForumTopicReactionEmote
▸ addForumTopicReactionEmote(channelID
, topicID
, emoteID
): Promise
<void
>
Add a reaction emote to a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
addListener
▸ addListener<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.addListener
Defined in
addReactionEmote
▸ addReactionEmote(channelID
, contentID
, emoteID
): Promise
<void
>
Add a reaction emote to any supported content type
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
contentID | string | The ID of the content |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
addServerMemberGroup
▸ addServerMemberGroup(groupID
, memberID
): Promise
<void
>
Add a server member to a group
Parameters
Name | Type | Description |
---|---|---|
groupID | string | The ID of the group |
memberID | string | The ID of the member |
Returns
Promise
<void
>
Defined in
addServerMemberRole
▸ addServerMemberRole(serverID
, memberID
, roleID
): Promise
<void
>
Add a role to a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
roleID | number | The ID of the role |
Returns
Promise
<void
>
Defined in
awardServerMember
▸ awardServerMember(serverID
, memberID
, amount
): Promise
<number
>
Award a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
amount | Omit <number , "total" > | The amount to award |
Returns
Promise
<number
>
Defined in
completeListItem
▸ completeListItem(channelID
, itemID
): Promise
<void
>
Complete a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
itemID | string | The ID of the item |
Returns
Promise
<void
>
Defined in
connect
▸ connect(): void
Connect the client to the Guilded gateway
Returns
void
Defined in
createCalendarEvent
▸ createCalendarEvent(channelID
, options
): Promise
<CalendarEvent
>
Create a calendar event
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | CalendarEventOptions | The options to create the event with |
Returns
Promise
<CalendarEvent
>
Defined in
createChannelMessage
▸ createChannelMessage<T
>(channelID
, options
): Promise
<ChatMessage
<T
>>
Create a channel message
Type parameters
Name | Type |
---|---|
T | extends TextChannel <T > = TextChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | MessageCreateOptions | The message options |
Returns
Promise
<ChatMessage
<T
>>
Defined in
createDoc
▸ createDoc(channelID
, options
): Promise
<Doc
>
Create a doc
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | DocOptions | The option to create the doc with |
Returns
Promise
<Doc
>
Defined in
createForumTopic
▸ createForumTopic<T
>(channelID
, options
): Promise
<ForumTopic
<T
>>
Create a forum topic
Type parameters
Name | Type |
---|---|
T | extends ForumChannel <T > = ForumChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | ForumTopicOptions | The forum topic options |
Returns
Promise
<ForumTopic
<T
>>
Defined in
createForumTopicComment
▸ createForumTopicComment(channelID
, topicID
, options
): Promise
<ForumTopicComment
>
Create a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
options | ForumTopicCommentOptions | The comment options |
Returns
Promise
<ForumTopicComment
>
Defined in
createListItem
▸ createListItem(channelID
, options
): Promise
<ListItem
>
Create a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | ListItemOptions | The list item options |
Returns
Promise
<ListItem
>
Defined in
createServerMemberBan
▸ createServerMemberBan(serverID
, memberID
, reason?
): Promise
<ServerMemberBan
>
Create a server member ban
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The Id othe member |
reason? | string | The reason for the ban |
Returns
Promise
<ServerMemberBan
>
Defined in
deleteCalendarEvent
▸ deleteCalendarEvent(channelID
, eventID
): Promise
<void
>
Delete a calender event
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
Returns
Promise
<void
>
Defined in
deleteCalendarEventRSVP
▸ deleteCalendarEventRSVP(channelID
, eventID
, memberID
): Promise
<void
>
Delete a calendar event RSVP
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
memberID | string | The ID of the member |
Returns
Promise
<void
>
Defined in
deleteChannelMessage
▸ deleteChannelMessage(channelID
, messageID
): Promise
<void
>
Delete a channel message
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
messageID | string | The ID of the message |
Returns
Promise
<void
>
Defined in
deleteDoc
▸ deleteDoc(channelID
, docID
): Promise
<void
>
Delete a doc
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
docID | number | The ID of the doc |
Returns
Promise
<void
>
Defined in
deleteForumTopic
▸ deleteForumTopic(channelID
, topicID
): Promise
<void
>
Delete a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<void
>
Defined in
deleteForumTopicComment
▸ deleteForumTopicComment(channelID
, topicID
, commentID
): Promise
<void
>
Delete a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
commentID | number | The ID of the forum comment |
Returns
Promise
<void
>
Defined in
deleteForumTopicCommentReactionEmote
▸ deleteForumTopicCommentReactionEmote(channelID
, topicID
, commentID
, emoteID
): Promise
<void
>
Delete a reaction emote from a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
commentID | number | The ID of the forum topic comment |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
deleteForumTopicReactionEmote
▸ deleteForumTopicReactionEmote(channelID
, topicID
, emoteID
): Promise
<void
>
Delete a reaction emote from a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
deleteListItem
▸ deleteListItem(channelID
, itemID
): Promise
<void
>
Delete a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
itemID | string | The ID of the item |
Returns
Promise
<void
>
Defined in
deleteReactionEmote
▸ deleteReactionEmote(channelID
, contentID
, emoteID
): Promise
<void
>
Delete a reaction emote
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
contentID | string | The ID of the content |
emoteID | number | The ID of the emote |
Returns
Promise
<void
>
Defined in
deleteServerChannel
▸ deleteServerChannel(channelID
): Promise
<void
>
Delete a server channel
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
Returns
Promise
<void
>
Defined in
deleteServerWebhook
▸ deleteServerWebhook(serverID
, webhookID
): Promise
<void
>
Delete a server webhook
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
webhookID | string | The ID of the webhook |
Returns
Promise
<void
>
Defined in
disconnect
▸ disconnect(): void
Disconnect the client from the Guilded gateway
Returns
void
Defined in
editCalendarEvent
▸ editCalendarEvent(channelID
, eventID
, options
): Promise
<CalendarEvent
>
Edit a calendar event
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the calendar event |
options | CalendarEventOptions | The options to edit the calendar event with |
Returns
Promise
<CalendarEvent
>
Defined in
editCalendarEventRSVP
▸ editCalendarEventRSVP(channelID
, eventID
, memberID
, options
): Promise
<CalendarEventRSVP
>
Edit a calendar event RSVP
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
memberID | string | The ID of the member |
options | CalendarEventRSVPEditOptions | The options to edit the RSVP with |
Returns
Promise
<CalendarEventRSVP
>
Defined in
editChannelMessage
▸ editChannelMessage<T
>(channelID
, messageID
, options
): Promise
<ChatMessage
<T
>>
Edit a channel message
Type parameters
Name | Type |
---|---|
T | extends TextChannel <T > = TextChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
messageID | string | The ID of the message |
options | MessageEditOptions | The new message options |
Returns
Promise
<ChatMessage
<T
>>
Defined in
editDoc
▸ editDoc(channelID
, docID
, options
): Promise
<Doc
>
Edit a doc
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
docID | number | The ID of the doc |
options | DocOptions | The options to edit the doc with |
Returns
Promise
<Doc
>
Defined in
editForumTopic
▸ editForumTopic<T
>(channelID
, topicID
, options
): Promise
<ForumTopic
<T
>>
Edit a forum topic
Type parameters
Name | Type |
---|---|
T | extends ForumChannel <T > = ForumChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
options | ForumTopicOptions | The options to edit the forum topic with |
Returns
Promise
<ForumTopic
<T
>>
Defined in
editForumTopicComment
▸ editForumTopicComment(channelID
, topicID
, commentID
, options
): Promise
<ForumTopicComment
>
Edit a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
commentID | number | The ID of the forum comment |
options | ForumTopicCommentOptions | The comment options |
Returns
Promise
<ForumTopicComment
>
Defined in
editListItem
▸ editListItem(channelID
, itemID
, options
): Promise
<ListItem
>
Edit a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
itemID | string | The ID of the item |
options | ListItemOptions | The options to edit the list item with |
Returns
Promise
<ListItem
>
Defined in
editServerChannel
▸ editServerChannel<T
>(channelID
, options
): Promise
<T
>
Edit the server channel
Type parameters
Name | Type |
---|---|
T | extends AnyChannel = AnyChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
options | ServerChannelEditOptions | The options to edit the channel with |
Returns
Promise
<T
>
Defined in
editServerMember
▸ editServerMember(serverID
, memberID
, options
): Promise
<void
>
Edit a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
options | ServerMemberEditOptions | The options to edit the member with |
Returns
Promise
<void
>
Defined in
editServerWebhook
▸ editServerWebhook(serverID
, webhookID
, options
): Promise
<Webhook
>
Edit a server webhook
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
webhookID | string | The ID of the webhook |
options | WebhookEditOptions | The options to edit the webhook with |
Returns
Promise
<Webhook
>
Defined in
emit
▸ emit<K
>(eventName
, ...args
): boolean
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
eventName | K |
...args | ClientEvents [K ] |
Returns
boolean
Inherited from
TypedEmitter.emit
Defined in
▸ emit<K
>(eventName
, ...args
): boolean
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
eventName | K |
...args | ClientEvents [K ] |
Returns
boolean
Inherited from
TypedEmitter.emit
Defined in
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 Symbol
s.
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
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
Returns
Promise
<CalendarEvent
>
Defined in
getCalendarEventRSVP
▸ getCalendarEventRSVP(channelID
, eventID
, memberID
): Promise
<CalendarEventRSVP
>
Get a calendar event RSVP
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
memberID | string | The ID of the member |
Returns
Promise
<CalendarEventRSVP
>
Defined in
getCalendarEventRSVPs
▸ getCalendarEventRSVPs(channelID
, eventID
): Promise
<CalendarEventRSVP
[]>
Get calendar event RSVPs
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
eventID | number | The ID of the event |
Returns
Promise
<CalendarEventRSVP
[]>
Defined in
getCalendarEvents
▸ getCalendarEvents(channelID
, filter
): Promise
<CalendarEvent
[]>
Get calendar events
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
filter | CalendarEventFilter | The options to filter the output |
Returns
Promise
<CalendarEvent
[]>
Defined in
getChannelMessage
▸ getChannelMessage<T
>(channelID
, messageID
): Promise
<ChatMessage
<T
>>
Get a channel message
Type parameters
Name | Type |
---|---|
T | extends TextChannel <T > = TextChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
messageID | string | The ID of the message |
Returns
Promise
<ChatMessage
<T
>>
Defined in
getChannelMessages
▸ getChannelMessages<T
>(channelID
, filter
): Promise
<ChatMessage
<T
>[]>
Get channel messages
Type parameters
Name | Type |
---|---|
T | extends TextChannel <T > = TextChannel |
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
filter | ChannelMessagesFilter | The options to filter the output |
Returns
Promise
<ChatMessage
<T
>[]>
Defined in
getDoc
▸ getDoc(channelID
, docID
): Promise
<Doc
>
Get a doc
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
docID | number | The ID of the doc |
Returns
Promise
<Doc
>
Defined in
getDocs
▸ getDocs(channelID
, filter
): Promise
<Doc
[]>
Get docs
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
filter | DocsFilter | The options to filter the output |
Returns
Promise
<Doc
[]>
Defined in
getForumTopic
▸ getForumTopic(channelID
, topicID
): Promise
<ForumTopic
<ForumChannel
>>
Get a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<ForumTopic
<ForumChannel
>>
Defined in
getForumTopicComment
▸ getForumTopicComment(channelID
, topicID
, commentID
): Promise
<ForumTopicComment
>
Get a forum topic comment
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
commentID | number | The ID of the forum topic comment |
Returns
Promise
<ForumTopicComment
>
Defined in
getForumTopicComments
▸ getForumTopicComments(channelID
, topicID
): Promise
<ForumTopicComment
[]>
Get forum topic comments
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the topic |
Returns
Promise
<ForumTopicComment
[]>
Defined in
getForumTopics
▸ getForumTopics(channelID
, filter
): Promise
<ForumTopic
<ForumChannel
>[]>
Get forum topics
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
filter | ForumTopicsFilter | The options to filter the output |
Returns
Promise
<ForumTopic
<ForumChannel
>[]>
Defined in
getListItem
▸ getListItem(channelID
, itemID
): Promise
<ListItem
>
Get a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
itemID | string | The ID of the list item |
Returns
Promise
<ListItem
>
Defined in
getListItems
▸ getListItems(channelID
): Promise
<ListItem
[]>
Get list items
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
Returns
Promise
<ListItem
[]>
Defined in
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
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
Returns
Promise
<Server
>
Defined in
getServerChannel
▸ getServerChannel(channelID
): Promise
<AnyChannel
>
Get a server channel
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
Returns
Promise
<AnyChannel
>
Defined in
getServerMember
▸ getServerMember(serverID
, memberID
): Promise
<ServerMember
>
Get a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
Returns
Promise
<ServerMember
>
Defined in
getServerMemberSocialLink
▸ getServerMemberSocialLink(serverID
, memberID
, socialMediaName
): Promise
<SocialLink
>
Get a social link of a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
socialMediaName | string | The name of the social media |
Returns
Promise
<SocialLink
>
Defined in
getServerMembers
▸ getServerMembers(serverID
): Promise
<ServerMember
[]>
Get server members
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
Returns
Promise
<ServerMember
[]>
Defined in
getServerWebhooks
▸ getServerWebhooks(serverID
, filter
): Promise
<Webhook
[]>
Get server webhooks
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
filter | WebhookFilter | The options to filter the output |
Returns
Promise
<Webhook
[]>
Defined in
getUser
▸ getUser(userID
): Promise
<User
>
Get a user
Parameters
Name | Type | Description |
---|---|---|
userID | string | The ID of the user |
Returns
Promise
<User
>
Defined in
listenerCount
▸ listenerCount(eventName
): number
Parameters
Name | Type |
---|---|
eventName | keyof ClientEvents |
Returns
number
Inherited from
TypedEmitter.listenerCount
Defined in
listeners
▸ listeners(eventName
): Function
[]
Parameters
Name | Type |
---|---|
eventName | keyof ClientEvents |
Returns
Function
[]
Inherited from
TypedEmitter.listeners
Defined in
lockForumTopic
▸ lockForumTopic(channelID
, topicID
): Promise
<void
>
Lock a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<void
>
Defined in
off
▸ off<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.off
Defined in
on
▸ on<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.on
Defined in
once
▸ once<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.once
Defined in
pinForumTopic
▸ pinForumTopic(channelID
, topicID
): Promise
<void
>
Pin a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<void
>
Defined in
prependListener
▸ prependListener<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.prependListener
Defined in
prependOnceListener
▸ prependOnceListener<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.prependOnceListener
Defined in
rawListeners
▸ rawListeners(eventName
): Function
[]
Parameters
Name | Type |
---|---|
eventName | keyof ClientEvents |
Returns
Function
[]
Inherited from
TypedEmitter.rawListeners
Defined in
removeAllListeners
▸ removeAllListeners(event?
): Client
Parameters
Name | Type |
---|---|
event? | keyof ClientEvents |
Returns
Inherited from
TypedEmitter.removeAllListeners
Defined in
removeListener
▸ removeListener<K
>(event
, listener
): Client
Type parameters
Name | Type |
---|---|
K | extends keyof ClientEvents |
Parameters
Name | Type |
---|---|
event | K |
listener | (...args : ClientEvents [K ]) => void |
Returns
Inherited from
TypedEmitter.removeListener
Defined in
removeServerMember
▸ removeServerMember(serverID
, memberID
): Promise
<void
>
Remove a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
Returns
Promise
<void
>
Defined in
removeServerMemberBan
▸ removeServerMemberBan(serverID
, memberID
): Promise
<void
>
Remove a server member ban
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
Returns
Promise
<void
>
Defined in
removeServerMemberGroup
▸ removeServerMemberGroup(groupID
, memberID
): Promise
<void
>
Remove a server member from a group
Parameters
Name | Type | Description |
---|---|---|
groupID | string | The ID of the group |
memberID | string | The Id of the member |
Returns
Promise
<void
>
Defined in
removeServerMemberRole
▸ removeServerMemberRole(serverID
, memberID
, roleID
): Promise
<void
>
Remove a role from a server member
Parameters
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
roleID | number | The ID of the role |
Returns
Promise
<void
>
Defined in
setMaxListeners
▸ setMaxListeners(n
): Client
By default EventEmitter
s 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
Name | Type |
---|---|
n | number |
Returns
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
Name | Type | Description |
---|---|---|
serverID | string | The ID of the server |
memberID | string | The ID of the member |
total | Omit <number , "amount" > | The total XP |
Returns
Promise
<number
>
Defined in
uncompleteListItem
▸ uncompleteListItem(channelID
, itemID
): Promise
<void
>
Uncomplete a list item
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
itemID | string | The ID of the item |
Returns
Promise
<void
>
Defined in
unlockForumTopic
▸ unlockForumTopic(channelID
, topicID
): Promise
<void
>
Unlock a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<void
>
Defined in
unpinForumTopic
▸ unpinForumTopic(channelID
, topicID
): Promise
<void
>
Unpin a forum topic
Parameters
Name | Type | Description |
---|---|---|
channelID | string | The ID of the channel |
topicID | number | The ID of the forum topic |
Returns
Promise
<void
>
Defined in
getEventListeners
▸ Static
getEventListeners(emitter
, name
): Function
[]
Returns a copy of the array of listeners for the event named eventName
.
For EventEmitter
s this behaves exactly the same as calling .listeners
on the emitter.
For EventTarget
s 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
Name | Type |
---|---|
emitter | EventEmitter | _DOMEventTarget |
name | string | 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 eventName
registered 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
Name | Type | Description |
---|---|---|
emitter | EventEmitter | The emitter to query |
eventName | string | symbol | The 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
Name | Type | Description |
---|---|---|
emitter | EventEmitter | - |
eventName | string | The 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 EventTarget 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
Name | Type |
---|---|
emitter | _NodeEventTarget |
eventName | string | 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
Name | Type |
---|---|
emitter | _DOMEventTarget |
eventName | string |
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
Name | Type | Description |
---|---|---|
n? | number | A 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