Error handling in loadChannelOptions func

This commit is contained in:
Corban-Lee Jones 2024-04-30 01:13:16 +01:00
parent b57e520b4e
commit c679b4fc40

View File

@ -283,13 +283,28 @@ async function loadChannelOptions(guildId) {
try {
const channels = await loadChannels(guildId);
// alert(JSON.stringify(channels, null, 4));
console.log(JSON.stringify(channels));
if (channels.message && channels.message.includes("rate limit")) {
throw new Error(
`${channels.message} Retry after ${channels.retry_after} seconds.`
)
}
if (channels.code === 50001) {
throw new Error(
`Unable to retrieve channels from Guild '${guildId}'.
Ensure that @PYRSS is a member with permissions
to view channels.`
);
}
channels.forEach(channel => {
if (channel.type !== 0)
return;
$("#subChannels").append($("<option>", {
text: channel.name,
text: "#" + channel.name,
value: channel.id
}));
});