Skip to content

Commit

Permalink
fixed welcome and goodbye messages appearing several times sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
energistix committed Jan 6, 2025
1 parent ec3443e commit fda3ddb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/listeners/traffic.guildMemberAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ export default new app.Listener({
if (!app.cache.ensure<boolean>("turn", true)) return
if (await app.isIgnored(member.guild.id)) return

const usersJoined: string[] = app.cache.ensure("usersJoined", [])
const usersLeft: string[] = app.cache.ensure("usersLeft", [])

if (usersJoined.includes(member.id)) return
usersJoined.push(member.id)
app.util.removeItem(usersLeft, member.id)

const config = await app.getGuild(member.guild, { forceExists: true })

await app.applyAutoRoles(member)
Expand Down Expand Up @@ -83,3 +90,4 @@ export default new app.Listener({
)
},
})

8 changes: 8 additions & 0 deletions src/listeners/traffic.guildMemberRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export default new app.Listener({

const config = await app.getGuild(member.guild)

const usersLeft: string[] = app.cache.ensure("usersLeft", [])
const usersJoined: string[] = app.cache.ensure("usersJoined", [])

if (usersLeft.includes(member.id)) return
usersLeft.push(member.id)
app.util.removeItem(usersJoined, member.id)

if (!config) return

if (member.user.bot) {
Expand Down Expand Up @@ -44,3 +51,4 @@ export default new app.Listener({
}
},
})

0 comments on commit fda3ddb

Please sign in to comment.