From 5e0fbb5caed6ce48494667fb497e14e9ea113991 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Thu, 12 May 2022 21:38:01 +0300 Subject: [PATCH] fix: only retry reminders in case of HTTP errors Doesn't make a lot of sense to keep trying to e.g. post a reminder in a deleted channel or a channel we have no perms to post in. --- .../src/plugins/Reminders/functions/postReminder.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/plugins/Reminders/functions/postReminder.ts b/backend/src/plugins/Reminders/functions/postReminder.ts index 665fc3fb..d96ad7b6 100644 --- a/backend/src/plugins/Reminders/functions/postReminder.ts +++ b/backend/src/plugins/Reminders/functions/postReminder.ts @@ -1,10 +1,10 @@ import { GuildPluginData } from "knub"; import { RemindersPluginType } from "../types"; import { Reminder } from "../../../data/entities/Reminder"; -import { Snowflake, TextChannel } from "discord.js"; +import { DiscordAPIError, HTTPError, Snowflake, TextChannel } from "discord.js"; import moment from "moment-timezone"; import { disableLinkPreviews } from "knub/dist/helpers"; -import { DBDateFormat, SECONDS } from "../../../utils"; +import { DBDateFormat, isDiscordHTTPError, SECONDS } from "../../../utils"; import humanizeDuration from "humanize-duration"; export async function postReminder(pluginData: GuildPluginData, reminder: Reminder) { @@ -31,10 +31,13 @@ export async function postReminder(pluginData: GuildPluginData= 500) { + // If we get a server error, try again later + return; + } } }