๐งโ๐งโ๐งโ๐ง Members
โน๏ธ Magic tipsโ
If you want to create "fake join" or "fake leave" to test you handlers, you can use builtin commands : join and leave.
๐ Multi eventsโ
There is 3 kinds of events here:
MemberAddโ (we will call itMemberJoin, it's easier to understand) when a user join a guildMemberRemoveโ (we will call itMemberLeave, it's easier to understand) when a user leave a guildMemberUpdateโ when a member (user inside a guild) is updated (e.g: new role)
Since we have 3 kinds of events, we can no longer simply put them in ./sources/modules/<module_name>/members,
we need to specify which of the 3 events is to be used. To do this, we add an extension to the end of the file:
joinโ to handleMemberAddleaveโ to handleMemberRemoveupdateโ to handleMemberUpdate
โฏ Example for each classes
replace <module_name> by the name of your module
joinโ./sources/modules/<module_name>/members/member_join.jsleaveโ./sources/modules/<module_name>/members/member_leave.jsupdateโ./sources/modules/<module_name>/members/member_update.js
๐ค "Member"โ
Member is an object with several data and methods, you should read
discord.js documentation to see
how to work with Member.
โ MemberJoinโ
Has one argument member who is an instance of Member.
async function parse(member)
{
console.log("new member:", member.user.username)
}
module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}
โ MemberLeaveโ
Possรจde un argument member qui est une instance de Member.
async function parse(member)
{
console.log("a member left:", member.user.username)
}
module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}
๐ MemberUpdateโ
Possรจde deux arguments old_member et new_member qui sont des instances de Member.
โ ๏ธ Attention: old_member est l'รฉtat du membre avant la mise ร jour et new_member aprรจs la mise ร jour.
async function parse(old_member, new_member)
{
console.log("member: ", old_member.user.username, " has been updated")
}
module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}
๐ฅ๏ธ Methods and parametersโ
Be careful MemberJoin and MemberLeave both has only one argument so as shown below:
async function parse(member)
While MemberUpdate has 2 arguments
async function parse(old_member, new_member)
โฏ Exports
At the bottom of the file we have exports, which includes several important elements.
module.exports = {
parse,
conditions: [],
any_guild: false,
dm: false,
allow_bots: false
}
parseโ method to handle the eventconditionsโ list of methods to check ifmemberhas the right conditionsany_guildโ if false, the command can be executed only on the main guilddmโ if true, we can use this interaction in direct messagesallow_botsโ if false, it will ignore events when the member is a bot