BS
Buape Studios•3mo ago
shum

Users aren't getting auto assigned role

When users reach a certain level, they aren't receiving the role for that level. At one point they were, and everything was working great, but it randomly stopped working.
15 Replies
Shadow
Shadow•3mo ago
Hmm that might have been related to one of our recent rewards changes, but it shouldn't have broken anything. What's your server's ID? (This is listed on /ping from Kiai)
shum
shumOP•3mo ago
1186638130745450506 thanks for helping! also i'm a coder for 7 years so don't be afraid to speak in code terms 😂 (if need be)
Shadow
Shadow•3mo ago
well here's what the issue was
diff --git a/apps/bot/src/bot/applicationCommands/settings/rewards.ts b/apps/bot/src/bot/applicationCommands/settings/rewards.ts
index 542463e2..d55177e1 100644
--- a/apps/bot/src/bot/applicationCommands/settings/rewards.ts
+++ b/apps/bot/src/bot/applicationCommands/settings/rewards.ts
@@ -582,7 +582,7 @@ export const syncRoleReward = async (roleId: string, guild: Guild) => {
const rewards = await getAllRoleRewards(guild.id)
const thisOne = rewards.find((r) => r.roleId === roleId)
if (!thisOne) throw new Error(`Reward for role ${roleId} not found`)
- const sorted = rewards.sort((a, b) => b.level - a.level)
+ const sorted = rewards.sort((a, b) => a.level - b.level)
const thisOneIndex = sorted.indexOf(thisOne)
const nextOne = sorted[thisOneIndex + 1]
diff --git a/apps/bot/src/bot/applicationCommands/settings/rewards.ts b/apps/bot/src/bot/applicationCommands/settings/rewards.ts
index 542463e2..d55177e1 100644
--- a/apps/bot/src/bot/applicationCommands/settings/rewards.ts
+++ b/apps/bot/src/bot/applicationCommands/settings/rewards.ts
@@ -582,7 +582,7 @@ export const syncRoleReward = async (roleId: string, guild: Guild) => {
const rewards = await getAllRoleRewards(guild.id)
const thisOne = rewards.find((r) => r.roleId === roleId)
if (!thisOne) throw new Error(`Reward for role ${roleId} not found`)
- const sorted = rewards.sort((a, b) => b.level - a.level)
+ const sorted = rewards.sort((a, b) => a.level - b.level)
const thisOneIndex = sorted.indexOf(thisOne)
const nextOne = sorted[thisOneIndex + 1]
shum
shumOP•3mo ago
ahhh the typical sort issue hahaha i've had a few prs like that at my job lol so it probably was sorting for the higher roles instead? and trying to assign it but no xp for that
Shadow
Shadow•3mo ago
it was assigning everyone the lowest reward and nothing more bc it kept filtering down its deploying now, and you should be able to just use /rewards sync to fix everyone's roles (or they'll fix next time they level up)
shum
shumOP•3mo ago
ohhhh sweet, i was going to ask about if there was a role i could assign thank you so much!!!!
Shadow
Shadow•3mo ago
np! bot is live with the changes now
shum
shumOP•3mo ago
thank you so much! yeah i guess it just still doesn't seem to really be doing much even after using /rewards sync
Kiai
Kiai•3mo ago
@shum claimed 10 XP from an XP drop!
shum
shumOP•3mo ago
😦
shum
shumOP•3mo ago
No description
shum
shumOP•3mo ago
like this person should have "Foreign Spy" by now and they are well into another level, but they still don't have it so they are stuck on bodies laughing right now (i just added the role manually to them right now, just in case there's any confusion)
Shadow
Shadow•3mo ago
The screenshot didn’t load at first and I was so confused by this 😂😂😂😂 I’ll take a look after work
shum
shumOP•3mo ago
thanks!
Shadow
Shadow•3mo ago
@shum try running /rewards sync and see if it works
Want results from more Discord servers?
Add your server