diff --git a/Myriad/Rest/Types/AllowedMentions.cs b/Myriad/Rest/Types/AllowedMentions.cs index d3ab3199..2c663ffc 100644 --- a/Myriad/Rest/Types/AllowedMentions.cs +++ b/Myriad/Rest/Types/AllowedMentions.cs @@ -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, diff --git a/Myriad/Serialization/JsonSnakeCaseStringEnumConverter.cs b/Myriad/Serialization/JsonSnakeCaseStringEnumConverter.cs new file mode 100644 index 00000000..5ff76513 --- /dev/null +++ b/Myriad/Serialization/JsonSnakeCaseStringEnumConverter.cs @@ -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); + } +} \ No newline at end of file diff --git a/PluralKit.Bot/Services/WebhookExecutorService.cs b/PluralKit.Bot/Services/WebhookExecutorService.cs index 9017bc30..39379cdf 100644 --- a/PluralKit.Bot/Services/WebhookExecutorService.cs +++ b/PluralKit.Bot/Services/WebhookExecutorService.cs @@ -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() + }; var webhookReq = new ExecuteWebhookRequest {