Fix error on @ everyone

This commit is contained in:
Ske 2021-03-18 11:34:35 +01:00
parent 1c548e9d7b
commit 4ee0c13d62
3 changed files with 25 additions and 2 deletions

View File

@ -1,9 +1,12 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Myriad.Serialization;
namespace Myriad.Rest.Types
{
public record AllowedMentions
{
[JsonConverter(typeof(JsonSnakeCaseStringEnumConverter))]
public enum ParseType
{
Roles,

View File

@ -0,0 +1,17 @@
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Myriad.Serialization
{
public class JsonSnakeCaseStringEnumConverter: JsonConverterFactory
{
private readonly JsonStringEnumConverter _inner = new(new JsonSnakeCaseNamingPolicy());
public override bool CanConvert(Type typeToConvert) =>
_inner.CanConvert(typeToConvert);
public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
_inner.CreateConverter(typeToConvert, options);
}
}

View File

@ -83,7 +83,10 @@ namespace PluralKit.Bot
var allowedMentions = content.ParseMentions();
if (!req.AllowEveryone)
allowedMentions = allowedMentions.RemoveUnmentionableRoles(guild);
allowedMentions = allowedMentions.RemoveUnmentionableRoles(guild) with {
// also clear @everyones
Parse = Array.Empty<AllowedMentions.ParseType>()
};
var webhookReq = new ExecuteWebhookRequest
{