Add Discord message overload handling

This commit is contained in:
Dominion
2023-04-16 17:32:24 -04:00
parent 2cc5e63130
commit f10361bc06
@@ -261,10 +261,20 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
ct: cancellationToken);
if (!result.IsSuccess)
{
Logger.LogWarning(
"Failed to send to channel {channelId}: {result}",
channelId,
result.LogFormat());
if (result.Error is RestResultError<RestError> restError && restError.Error.Code == DiscordError.InvalidFormBody)
await channelsClient.CreateMessageAsync(
channelId,
"TGS: Could not send message to Discord. Body was malformed or too long",
messageReference: replyToReference,
allowedMentions: allowedMentions,
ct: cancellationToken);
}
}
try