Events - Client

Events here are to be used directly on the Client.

Assuming:

var client = new Discord.Client();

ready

Signals that the library has connected successfully to Discord, received and sorted all immediate data, and is now ready to be interacted with.

client.on('ready', function(event) { });

disconnect

The library has either disconnected from Discord or failed to log in after a .connect() call. If it's the former, the code will be a WebSocket Error Code (1xxx - 4xxx). If it's the latter, the code will be 0.

client.on('disconnect', function(errMsg, code) { });

Warning: disconnect event

It's recommended that you have a disconnect event listener with client.connect().

message

client.on('message', function(user, userID, channelID, message, event) { });
  • {String} user : The user's name.
  • {String} userID : The user's ID.
  • {String} channelID : The ID of the room where the bot received the message.
  • {String} message : The chat message.

presence

client.on('presence', function(user, userID, status, game, event) { });
  • {String} user : The user's name.
  • {String} userID : The user's ID.
  • {String} status : The user's status. Currently observed: ['online', 'idle', 'offline']
  • {Object} game : The entire object containing the name (String), type (Number) and possibly url (String/null).

any

This event gives you ANY websocket message sent to your client. Useful if you want to create custom events for certain actions. The schema for these events are listed here: http://hornwitser.no/discord/analysis.

client.on('any', function(event) { });

WebSocket camelCased events


These events are the WebSocket events automatically converted to camelCased Node events via a function in the backend. The final callback argument is the full WebSocket event.

WebSocket event Node event Callback Arguments
MESSAGE_CREATE messageCreate (username, userID, channelID, message)
MESSAGE_UPDATE messageUpdate (oldMsg?, newMsg)
PRESENCE_UPDATE presenceUpdate ()
USER_UPDATE userUpdate ()
USER_SETTINGS_UPDATE userSettingsUpdate ()
GUILD_CREATE guildCreate (server)
GUILD_UPDATE guildUpdate (oldServer, newServer)
GUILD_DELETE guildDelete (server)
GUILD_MEMBER_ADD guildMemberAdd (member)
GUILD_MEMBER_UPDATE guildMemberUpdate (oldMember, newMember)
GUILD_MEMBER_REMOVE guildMemberRemove (member)
GUILD_ROLE_CREATE guildRoleCreate (role)
GUILD_ROLE_UPDATE guildRoleUpdate (oldRole, newRole)
GUILD_ROLE_DELETE guildRoleDelete (role)
CHANNEL_CREATE channelCreate (channel)
CHANNEL_UPDATE channelUpdate (oldChannel, newChannel)
CHANNEL_DELETE channelDelete (channel)
VOICE_STATE_UPDATE voiceStateUpdate ()
VOICE_SERVER_UPDATE voiceServerUpdate ()
GUILD_MEMBERS_CHUNK guildMembersChunk ()

results matching ""

    No results matching ""