fix(bot): filter out non-rich Discord embeds in reproxy (#476)
This commit is contained in:
parent
62a57bc818
commit
fcd1ec486e
@ -229,7 +229,7 @@ public class ProxyService
|
||||
throw new PKError("You don't have permission to send messages in the channel that message is in.");
|
||||
|
||||
// Mangle embeds (for reply embed color changing)
|
||||
var mangledEmbeds = originalMsg.Embeds!.Select(embed => MangleReproxyEmbed(embed, member)).ToArray();
|
||||
var mangledEmbeds = originalMsg.Embeds!.Select(embed => MangleReproxyEmbed(embed, member)).Where(embed => embed != null).ToArray();
|
||||
|
||||
// Send the reproxied webhook
|
||||
var proxyMessage = await _webhookExecutor.ExecuteWebhook(new ProxyRequest
|
||||
@ -271,7 +271,7 @@ public class ProxyService
|
||||
}
|
||||
}
|
||||
|
||||
private Embed MangleReproxyEmbed(Embed embed, ProxyMember member)
|
||||
private Embed? MangleReproxyEmbed(Embed embed, ProxyMember member)
|
||||
{
|
||||
// XXX: This is a naïve implementation of detecting reply embeds: looking for the same Unicode
|
||||
// characters as used in the reply embed generation, since we don't _really_ have a good way
|
||||
@ -290,6 +290,12 @@ public class ProxyService
|
||||
};
|
||||
}
|
||||
|
||||
// XXX: remove non-rich embeds as including them breaks link embeds completely
|
||||
else if (embed.Type != "rich")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return embed;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user