generated from Baipyrus/DiscordJS-Template
implement guild member add event
This commit is contained in:
parent
580b54c549
commit
cfc714611e
@ -1,7 +1,20 @@
|
||||
import { Events, GuildMember } from 'discord.js';
|
||||
import { Role } from '../../../database.js';
|
||||
|
||||
export const name = Events.GuildMemberAdd;
|
||||
/** @param {GuildMember} member */
|
||||
export function execute(member) {
|
||||
console.log(member);
|
||||
export async function execute(member) {
|
||||
// Find roles to be assigned in guild from database
|
||||
const roles = await Role.findAll({
|
||||
where: {
|
||||
guild: member.guild.id,
|
||||
assign: true
|
||||
}
|
||||
});
|
||||
|
||||
// Ignore if no none found
|
||||
if (roles.length === 0) return;
|
||||
|
||||
// Add roles to member
|
||||
member.roles.add(roles.map((role) => role.id));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user