aboutsummaryrefslogtreecommitdiff
path: root/src/listeners/member-custom
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-06 12:28:26 -0500
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2022-01-06 12:28:26 -0500
commita48dc88637d7b3e41a78eaeda91a19a967b278ff (patch)
tree6ef9f15683205fb10161c2db3d04fa35b2cc4238 /src/listeners/member-custom
parent10331e32e00116a4a82b4f86f668aaffa5ca903d (diff)
downloadtanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.tar.gz
tanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.tar.bz2
tanzanite-a48dc88637d7b3e41a78eaeda91a19a967b278ff.zip
fix a few things, add level roles (finally)
Diffstat (limited to 'src/listeners/member-custom')
-rw-r--r--src/listeners/member-custom/bushLevelUpdate.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/listeners/member-custom/bushLevelUpdate.ts b/src/listeners/member-custom/bushLevelUpdate.ts
index 18b0fc2..6299a36 100644
--- a/src/listeners/member-custom/bushLevelUpdate.ts
+++ b/src/listeners/member-custom/bushLevelUpdate.ts
@@ -24,5 +24,25 @@ export default class BushLevelUpdateListener extends BushListener {
if (!success) await client.console.warn('bushLevelUpdate', `Could not send level up message in ${message.guild}`);
})();
}
+ void (async () => {
+ const levelRoles = await message.guild.getSetting('levelRoles');
+ if (Object.keys(levelRoles).length) {
+ const promises = [];
+ for (let i = 0; i < newLevel; i++) {
+ if (levelRoles[i]) {
+ if (member.roles.cache.has(levelRoles[i])) continue;
+ else promises.push(member.roles.add(levelRoles[i]));
+ }
+ }
+ try {
+ if (promises.length) await Promise.all(promises);
+ } catch (e) {
+ await member.guild.error(
+ 'bushLevelUpdate',
+ `There was an error adding level roles to ${member.user.tag} upon reaching to level ${newLevel}.\n${e?.message ?? e}`
+ );
+ }
+ }
+ })();
}
}