You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discordallevents!
A quick and dirty fleshing out of the discord.jseventlisteners
(not tested at all!)
listed here ->https://discord.js.org/#/docs/main/stable/class/Client
Saved to->https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584
Note
use discordjs-logger version 4 for discord.js@14 or greater Docs
use discordjs-logger version 3 for discord.js@13 or less than Docs
If you see that: [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted
import{Client,GatewayIntentBits,Partials}from"discord.js";constclient=newClient({intents: [GatewayIntentBits.Guilds,GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildBans,GatewayIntentBits.GuildEmojisAndStickers,GatewayIntentBits.GuildIntegrations,GatewayIntentBits.GuildWebhooks,GatewayIntentBits.GuildInvites,GatewayIntentBits.GuildPresences,GatewayIntentBits.GuildMessages,GatewayIntentBits.GuildMessageReactions,GatewayIntentBits.GuildMessageTyping,GatewayIntentBits.DirectMessages,GatewayIntentBits.DirectMessageReactions,GatewayIntentBits.DirectMessageTyping,GatewayIntentBits.MessageContent,GatewayIntentBits.GuildScheduledEvents,],partials: [Partials.User,Partials.Channel,Partials.GuildMember,Partials.Message,Partials.Reaction,Partials.GuildScheduledEvent,Partials.ThreadMember,],});// Add more intents if you wanna debugimportDiscordLoggerfrom"discordjs-logger";constlogger=newDiscordLogger(client);logger.debug();client.login("YOUR_DISCORD_APP_TOKEN");
channelPinsUpdate(): Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event, not much information can be provided easily here - you need to manually check the pins yourself.
ready(): Emitted when the client becomes ready to start working.
PARAMETER
TYPE
DESCRIPTION
client.on("ready",function(){console.log(`the client becomes ready to start`);console.log(`I am ready! Logged in as ${client.user.tag}!`);console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);client.user.setActivity("the upright organ");client.generateInvite(["SEND_MESSAGES","MANAGE_GUILD","MENTION_EVERYONE"]).then((link)=>{console.log(`Generated bot invite link: ${link}`);inviteLink=link;});});
reconnecting(): Emitted whenever the client tries to reconnect to the WebSocket.
PARAMETER
TYPE
DESCRIPTION
client.on("reconnecting",function(){console.log(`client tries to reconnect to the WebSocket`);});
resume(): Emitted whenever a WebSocket resumes.
PARAMETER
TYPE
DESCRIPTION
replayed
number
The number of events that were replayed
client.on("resume",function(replayed){console.log(`whenever a WebSocket resumes, ${replayed} replays`);});
roleCreate(): Emitted whenever a role is created.
PARAMETER
TYPE
DESCRIPTION
role
Role
The role that was created
client.on("roleCreate",function(role){console.error(`a role is created`);});
roleDelete(): Emitted whenever a guild role is deleted.
PARAMETER
TYPE
DESCRIPTION
role
Role
The role that was deleted
client.on("roleDelete",function(role){console.error(`a guild role is deleted`);});
roleUpdate(): Emitted whenever a guild role is updated.
PARAMETER
TYPE
DESCRIPTION
oldRole
Role
The role before the update
newRole
Role
The role after the update
client.on("roleUpdate",function(oldRole,newRole){console.error(`a guild role is updated`);});
typingStart(): Emitted whenever a user starts typing in a channel.
PARAMETER
TYPE
DESCRIPTION
channel
Channel
The channel the user started typing in
user
User
The user that started typing
client.on("typingStart",function(channel,user){console.log(`${user.tag} has started typing`);});
typingStop(): Emitted whenever a user stops typing in a channel.
PARAMETER
TYPE
DESCRIPTION
channel
Channel
The channel the user stopped typing in
user
User
The user that stopped typing
client.on("typingStop",function(channel,user){console.log(`${user.tag} has stopped typing`);});
userNoteUpdate(): Emitted whenever a note is updated.
PARAMETER
TYPE
DESCRIPTION
user
User
The user the note belongs to
oldNote
String
The note content before the update
newNote
String
The note content after the update
client.on("userNoteUpdate",function(user,oldNote,newNote){console.log(`a member's note is updated`);});
userUpdate(): Emitted whenever a user's details (e.g. username) are changed.
PARAMETER
TYPE
DESCRIPTION
oldUser
User
The user before the update
newUser
User
The user after the update
client.on("userUpdate",function(oldUser,newUser){console.log(`user's details (e.g. username) are changed`);});
voiceStateUpdate(): Emitted whenever a user changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
PARAMETER
TYPE
DESCRIPTION
oldMember
GuildMember
The member before the voice state update
newMember
GuildMember
The member after the voice state update
client.on("voiceStateUpdate",function(oldMember,newMember){console.log(`a user changes voice state`);});