diff --git a/src/discord/events/guildMemberAdd.ts b/src/discord/events/guildMemberAdd.ts index 1dccfc198..e514c6c50 100644 --- a/src/discord/events/guildMemberAdd.ts +++ b/src/discord/events/guildMemberAdd.ts @@ -3,6 +3,7 @@ import { } from '../@types/eventDef'; import trust from '../utils/trust'; +import { giveMilestone } from '../../global/utils/experience'; // eslint-disable-next-line @typescript-eslint/no-unused-vars const F = f(__filename); @@ -29,6 +30,8 @@ export const guildMemberAdd: GuildMemberAddEvent = { if (!guildData.cooperative) return; + // Assign level role upon join. Re-assigns if they had a role previously. + await giveMilestone(member, true); await trust(member); } catch (err) { log.error(F, `Error: ${err}`); diff --git a/src/global/utils/experience.ts b/src/global/utils/experience.ts index 55d05d3a6..cbd869b17 100644 --- a/src/global/utils/experience.ts +++ b/src/global/utils/experience.ts @@ -74,6 +74,7 @@ export async function getTotalLevel( export async function giveMilestone( member:GuildMember, + newMember = false, ) { const userData = await db.users.upsert({ where: { @@ -188,7 +189,7 @@ export async function giveMilestone( if (!member.roles.cache.has(role.id)) { // log.debug(F, `Giving ${member.displayName} role ${role.name} (${role.id})`); await member.roles.add(role); - if (levelTier >= 2) { + if (levelTier >= 2 && !newMember) { const channel = await member.guild?.channels.fetch(env.CHANNEL_VIPLOUNGE) as TextChannel; await channel.send(`${emojis} **${member} has reached Total level ${levelTier}0!** ${emojis}`); } @@ -250,11 +251,7 @@ export async function experience( await db.user_experience.create({ data: newUser, }); - if (type === 'TEXT') { - // Give the user the VIP 0 role the first time they talk - const role = await channel.guild?.roles.fetch(env.ROLE_VIP_0) as Role; - await member.roles.add(role); - } + return; }