Events - SinisterRectus/Discordia GitHub Wiki
Discordia uses an event emitter class to broadcast various named events, most of which originate from Discord's gateway via WebSocket payloads. This is a list of all Discordia client events and their arguments.
Event Emitters
The Client class extends the Emitter class. This makes it acceptable to subscribe callbacks or listeners to client events. The callbacks are fired when the events are emitted. All of the events listed here are called by the Discordia library and should not be manually emitted by the user.
For example, a listener can be subscribed to the messageCreate
event:
local client = discordia.Client()
client:on('messageCreate', function(message)
print(message.author.username, message.content)
end)
This event would print the message's author's name and the message content every time Discordia receives an event for a message creation from Discord.
Discord Events
ready
Emitted after all shards and guilds are fully loaded.
- no arguments
shardReady
Emitted after a shard successfully connects to a Discord gateway and loads all corresponding guilds.
shardId
- ID of the shard
shardResumed
Emitted after the client successfully resumes a severed gateway connection.
shardId
- ID of the shard
channelCreate
Emitted when a guild channel is created, when a private channel is opened, or when a group channel is joined.
channel
- the created channel
channelUpdate
Emitted when a channel property is updated, such as its name, topic, bitrate, etc.
channel
- the updated channel
channelDelete
Emitted when a guild channel is deleted, when a private channel is closed, or when a group channel is left.
channel
- the deleted channel
recipientAdd
Emitted when a new recipient is added to a group channel. User-accounts only.
channel
- the group channel to which the user was addeduser
- the user that was added
recipientRemove
Emitted when a new recipient is removed from a group channel. User-accounts only.
channel
- the group channel from which the user was removeduser
- the user that was removed
guildAvailable
Emitted when a guild becomes available. This can occur after a server outage or as guild data is streamed in after login.
guild
- the available guild
guildCreate
Emitted when a guild is created from the perspective of the current user, usually after the client user joins a new one.
guild
- the created guild
guildUpdate
Emitted when a guild property is updated such as its name, region, icon, etc.
guild
- the updated guild
guildUnavailable
Emitted when a guild becomes unavailable, potentially due to a server outage. Unavailable guilds may lack significant data.
guild
- the unavailable guild
guildDelete
Emitted when a guild is deleted from the perspective of the current user, usually after the client leaves one.
guild
- the deleted guild
userBan
Emitted when a user is banned from a guild.
user
- the user that was bannedguild
- the guild from which the user was banned
userUnban
Emitted when a user is unbanned from a guild.
user
- the user that was unbannedguild
- the guild from which the user was unbanned
emojisUpdate
Emitted when a guild's custom emoji is updated.
guild
- the guild in which the emoji exists
memberJoin
Emitted when a new user joins a guild.
member
- the member that joined the guild
memberLeave
Emitted when a user leaves a guild.
member
- the member that left the guild
memberUpdate
Emitted when a guild member property is updated, such as its roles or nickname. See presenceUpdate for status changes.
member
- the member that was updated
roleCreate
Emitted when a guild role is created.
role
- the role that was created
roleUpdate
Emitted when a guild role property is updated, such as its name, color, permissions, etc.
role
- the role that was updated
roleDelete
Emitted when a guild role is deleted.
role
- the role that was deletes
messageCreate
Emitted when a text channel message is created.
message
- the message that was created
messageUpdate
Emitted when the content of a text channel message is edited.
message
- the message that was updated
messageUpdateUncached
Emitted when the content of a text channel message is edited, but the message is not cached by the client.
channel
- the channel in which the message was createdmessageId
- the Snowflake ID of the message
messageDelete
Emitted when a text channel message is deleted. Bulk deletions will fire this for every message that is deleted.
message
- the message that was deleted
messageDeleteUncached
Emitted when a text channel message is deleted, but the message is not cached by the client. Bulk deletions will fire this for every message that is deleted, but not cached.
channel
- the channel in which the message was deletedmessageId
- the Snowflake ID of the message
reactionAdd
Emitted when an emoji reaction is added to message.
reaction
- the reaction object that was addeduserId
- the Snowflake ID of the user that added the reaction
reactionAddAny
Emitted when an emoji reaction is added to message, whether the message is cached or not.
This event will be emitted before reactionAdd
/reactionAddUncached
are emitted.
channel
- the channel in which the reaction was addedmessageId
- The Snowflake ID of the reacted messagehash
- the hash of the reaction; either an emoji ID or emoji nameuserId
- the Snowflake ID of the user that added the reaction
reactionAddUncached
Emitted when an emoji reaction is added to message, but the message is not cached by the client.
channel
- the channel in which the reaction was addedmessageId
- the Snowflake ID of the reacted messagehash
- the hash of the reaction; either an emoji ID or emoji nameuserId
- the Snowflake ID of the user that added the reaction
reactionRemove
Emitted when an emoji reaction is removed from a message.
reaction
- the reaction object that was removeduserId
- the Snowflake ID of the user whose reaction was removed
reactionRemoveAny
Emitted when an emoji reaction is removed from a message, whether the message is cached or not.
This event will be emitted before reactionRemove
/reactionRemoveUncached
are emitted.
channel
- the channel in which the reaction was removedmessageId
- the Snowflake ID of the reacted messagehash
- the hash of the reaction; either an emoji ID or emoji nameuserId
- the Snowflake ID of the user whose reaction was removed
reactionRemoveUncached
Emitted when an emoji reaction is removed from a message, but the message is not cached by the client.
channel
- the channel in which the reaction was removedmessageId
- the Snowflake ID of the reacted messagehash
- the hash of the reaction; either an emoji ID or emoji nameuserId
- the Snowflake ID of the user whose reaction was removed
reactionRemoveAll
Emitted when all emoji reactions are removed from a message.
message
- the message from which the reactions were removed
reactionRemoveAllAny
Emitted when all emoji reactions are removed from a message, whether the message is cached or not.
This event will be emitted before reactionRemoveAll
/reactionRemoveAllUncached
are emitted.
channel
- the channel in which the reactions were removedmessageId
- the Snowflake ID of the reacted message
reactionRemoveAllUncached
Emitted when all emoji reactions are removed from a message, but the message is not cached by the client.
channel
- the channel in which the reactions were removedmessageId
- the Snowflake ID of the reacted message
pinsUpdate
Emitted when a message is pinned or unpinned in a channel.
channel
- the channel in which the message was pinned or unpinned
presenceUpdate
Emitted when a guild member's status or user properties change. See memberUpdate for role and nickname changes.
member
- the member whose presence has changed
relationshipUpdate
Emitted when a relationship's (friend, blocked user) status or user properties change. User-accounts only.
relationship
- the relationship that was updated
relationshipAdd
Emitted when a relationship (friend, blocked user) is added. User-accounts only.
relationship
- the relationship that was added
relationshipRemove
Emitted when a relationship (friend, blocked user) is removed. User-accounts only.
relationship
- the relationship that was removed
typingStart
Emitted when a user starts typing in a text channel.
userId
- the Snowflake ID of the user that started typingchannelId
- the Snowflake ID of the channel in which the user started typingtimestamp
- Unix timestamp in seconds at which the user started typing
userUpdate
Emitted when the client user updates itself.
user
- the user that was updated (equivalent toclient.user
)
voiceConnect
Emitted when a guild member connects to voice chat.
member
- the member that connected
voiceDisconnect
Emitted when a guild member disconnects from voice chat.
member
- the member that connected
voiceUpdate
Emitted when a guild member's mute/deaf status changes.
member
- the member that connected
voiceChannelJoin
Emitted when a guild member joins a voice channel.
member
- the member that joinedchannel
- the channel that was joined
voiceChannelLeave
Emitted when a guild member leaves a voice channel.
member
- the member that leftchannel
- the channel that was left
webhooksUpdate
Emitted when a guild's text channel's webhooks have updated.
channel
- the channel in which the webhook updated
Logging Events
debug
Emitted to provide detailed information regarding specific library behavior.
debug
- The unformatted debug message
info
Emitted to provide helpful information regarding general library behavior.
message
- The unformatted info message
warning
Emitted when something went wrong, but your code will probably continue operating normally.
message
- The unformatted warning message
error
Emitted when something went wrong and your code may not continue operating normally.
message
- The unformatted error message
Other Events
heartbeat
Emitted when Discord responds with a heartbeat acknowledgement.
shardId
- the ID of the shard that received the acknowledgementlatency
- round-trip latency of the heartbeat in milliseconds
raw
Emitted for every Discord gateway event.
string
- Raw JSON string of the gateway payload