Skip to content

Commit

Permalink
fix: add optional chain on possibly null objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Jul 29, 2024
1 parent cf7550e commit b8f645b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/services/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class DiscordService {
},
);

const guildRoles = guildRolesResponse.data;
const guildRoles = guildRolesResponse?.data;

let highestRole: any = null;

guildRoles.forEach((role: any) => {
if (guildUser.roles.includes(role.id)) {
if (guildUser?.roles.includes(role.id)) {
if (!highestRole) {
highestRole = role;
} else if (role.position > highestRole.position) {
Expand Down

0 comments on commit b8f645b

Please sign in to comment.