Skip to content

Commit

Permalink
chore: ignore all discord runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jan 11, 2024
1 parent 786f35e commit 5598ea6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/providers/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
EmbedBuilder,
codeBlock,
underscore,
inlineCode
inlineCode,
DiscordAPIError
} from 'discord.js';
import db from '../helpers/mysql';
import removeMd from 'remove-markdown';
Expand Down Expand Up @@ -146,6 +147,9 @@ const checkPermissions = async (channelId, botId) => {
return `I do not have permission to send messages in this channel ${discordChannel.toString()}, Add permission and try again`;
return true;
} catch (error) {
if (!(error instanceof DiscordAPIError)) {
capture(error);
}
console.error('[discord] error checking permissions', error);
const channelExistWithName = client.channels.cache.find(
c => c.name === channelId
Expand Down Expand Up @@ -319,8 +323,11 @@ export const sendMessage = async (channel, message) => {
await speaker.send(message);
success = true;
return true;
} catch (e) {
console.error('[discord] Failed to send message', channel, e);
} catch (error) {
if (!(error instanceof DiscordAPIError)) {
capture(error);
}
console.error('[discord] Failed to send message', channel, error);
} finally {
end({ status: success ? 200 : 500 });
}
Expand Down

0 comments on commit 5598ea6

Please sign in to comment.