Don't attempt to create a reply embed when message fetching fails

This commit is contained in:
Ske 2021-01-14 03:21:56 +01:00
parent 1c4b972f65
commit e0cc74a712

View File

@ -102,9 +102,14 @@ namespace PluralKit.Bot
if (trigger.Reference?.Channel?.Id == trigger.ChannelId) if (trigger.Reference?.Channel?.Id == trigger.ChannelId)
{ {
var repliedTo = await FetchReplyOriginalMessage(trigger.Reference); var repliedTo = await FetchReplyOriginalMessage(trigger.Reference);
var embed = await CreateReplyEmbed(repliedTo); if (repliedTo != null)
if (embed != null) {
embeds.Add(embed); var embed = CreateReplyEmbed(repliedTo);
if (embed != null)
embeds.Add(embed);
}
// TODO: have a clean error for when message can't be fetched instead of just being silent
} }
// Send the webhook // Send the webhook
@ -137,7 +142,7 @@ namespace PluralKit.Bot
return null; return null;
} }
private async Task<DiscordEmbed> CreateReplyEmbed(DiscordMessage original) private DiscordEmbed CreateReplyEmbed(DiscordMessage original)
{ {
var content = new StringBuilder(); var content = new StringBuilder();