Skip to content

Commit

Permalink
fix/undefined roles (#435)
Browse files Browse the repository at this point in the history
* fix: roles undefined on auto attribution

* feat: linter

---------

Co-authored-by: JustDams <noreply@github.com>
  • Loading branch information
JustDams and web-flow authored Oct 18, 2024
1 parent 9702cc7 commit 8e45ed7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const getRoleIds = (guildRoles) => Object.keys(Object.entries(guildRoles)[2][1])
.filter(e => e.startsWith('level')).map(e => guildRoles[e])

const getCustomRoles = async (guildId) => {
const roleIds = getRoleIds(await GuildRoles.getRolesOf(guildId))
const roles = await GuildRoles.get(guildId)
if (!roles) return

const roleIds = getRoleIds(roles)
return Object.entries(color.levels[defaultGame]).map(([level, range], index) => {
return {
guildId: guildId,
Expand All @@ -31,6 +34,7 @@ const setupRoles = async (client, user, guildId, remove) => {

const activeGuildSubscriptions = await getActiveGuildsEntitlements(client)
const roles = activeGuildSubscriptions.has(guildDatas.id) ? await GuildCustomRole.getRolesOf(guildDatas.id) : await getCustomRoles(guildDatas.id)
if (!roles) return

members?.forEach(async (member) => {
if (!member?.user) return
Expand Down

0 comments on commit 8e45ed7

Please sign in to comment.