Skip to content

Commit

Permalink
fix: catch error where broadcast eval crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhuh committed Jun 7, 2023
1 parent 7844852 commit 0d897b2
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions commands/react/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,26 @@ export class CreateSubcommand extends SlashSubCommand {
id: string | null;
}
) {
const emojis = (
await interaction.client.shard?.broadcastEval((c) =>
c.guilds.cache.map((g) => g.emojis.cache)
)
)?.flat(3);

if (!emojis || !emojis.length) {
this.log.error(`Failed to get guild emojis.`);
return false;
}
try {
const emojis = (
await interaction.client.shard?.broadcastEval((c) =>
c.guilds.cache.map((g) => g.emojis.cache)
)
)?.flat(3);

if (!emojis || !emojis.length) {
this.log.error(`Failed to get guild emojis.`);
return false;
}

return emojis.find((e) => e.id === emoji.id && emoji.id !== null);
return emojis.find((e) => e.id === emoji.id && emoji.id !== null);
} catch (e) {
this.log.critical(
`Failed to broadcastEval emojis.\n${e}`,
interaction.guildId
);

return null;
}
}
}

0 comments on commit 0d897b2

Please sign in to comment.