Skip to content

Commit

Permalink
style: explain why no checks are made before removing roles
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed Mar 10, 2024
1 parent 7aee88c commit b4d7c6d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/modules/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ client.on(Events.PresenceUpdate, async (oldMember, newMember) => {
activeTemporaryRoles.forEach(activeTemporaryRole => {
if (!tempRoleIDsToBeAdded.has(activeTemporaryRole.roleID)) {
const role = newMember.guild?.roles.cache.get(activeTemporaryRole.roleID);
// this does not check if the user has the role on purpose:
// trying to remove it when the user doesn’t have it does nothing
// and the local role cache *could* be invalid resulting in roles getting stuck
if (role) newMember.member?.roles.remove(role);
prepare(
'DELETE FROM activeTemporaryRoles WHERE guildID = ? AND userIDHash = ? AND roleID = ?'
Expand Down

0 comments on commit b4d7c6d

Please sign in to comment.