Skip to content

Commit

Permalink
Fix profile not rendering when user isn't in support server
Browse files Browse the repository at this point in the history
  • Loading branch information
WinG4merBR committed Jan 19, 2025
1 parent 8ef56a7 commit 8381820
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class GetUserRolesFromAGuild {
return@get
}

val member = guild.retrieveMemberById(userId).await() ?: run {
val member = try {
guild.retrieveMemberById(userId).await()
} catch (e: Exception) {
call.respond(HttpStatusCode.NotFound, null)
return@get
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,21 @@ class ProfileRender(
context.db.utils.profile.getBadges()
}

val roles = context.foxy.shardManager.getGuildById(Constants.SUPPORT_SERVER_ID)
?.retrieveMember(user)
?.await()
?.roles
?.map { it.id } ?: run {
logger.info { "Guild not found on this cluster" }
ClusterUtils.getMemberRolesFromCluster(context.foxy, Constants.SUPPORT_SERVER_ID.toLong(), user.idLong)
val roles = try {
context.foxy.shardManager.getGuildById(Constants.SUPPORT_SERVER_ID)
?.retrieveMember(user)
?.await()
?.roles
?.map { it.id } ?: run {
logger.info { "Guild not found on this cluster" }
ClusterUtils.getMemberRolesFromCluster(context.foxy, Constants.SUPPORT_SERVER_ID.toLong(), user.idLong)
}
} catch (e: Exception) {
null
}

val userBadges = BadgeUtils.getBadges(roles, defaultBadges, data)
val userBadges = roles?.let { BadgeUtils.getBadges(it, defaultBadges, data) }
?: BadgeUtils.getFallbackBadges(defaultBadges, data)

if (userBadges.isEmpty()) {
return
Expand Down

0 comments on commit 8381820

Please sign in to comment.