Skip to content

Commit

Permalink
Don't throw errors when Discord channel is not found (#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrrikkotua authored Sep 12, 2023
1 parent fd98789 commit f08a660
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ export const getMessage = async (
const response = await axios(config)
return response.data
} catch (err) {
const newErr = handleDiscordError(err, config, { channelId, messageId }, ctx)
throw newErr
if (
err.response &&
err.response.data &&
err.response.data.message === 'Unknown Channel' &&
err.response.data.code === 10003
) {
ctx.log.warn(
{ channelId, messageId },
'Discord API returned Unknown Channel error when fetching message during webhook processing, skipping message.',
)
return null
} else {
const newErr = handleDiscordError(err, config, { channelId, messageId }, ctx)
throw newErr
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const parseWebhookMessage = async (payload: any, ctx: IProcessWebhookStreamConte
ctx as IProcessStreamContext,
)

if (!record) {
// skipping 404 errors, they are most likely due to the message / channel being deleted
return
}

let parent: string | undefined
let parentChannel: string | undefined

Expand Down

0 comments on commit f08a660

Please sign in to comment.