2024-04-08 16:38:03 +03:00
|
|
|
using System.Text.Json.Nodes;
|
|
|
|
using Remora.Results;
|
|
|
|
|
2024-06-02 07:56:12 +03:00
|
|
|
namespace TeamOctolings.Octobot.Data.Options;
|
2024-04-08 16:38:03 +03:00
|
|
|
|
|
|
|
/// <inheritdoc />
|
2024-06-02 07:56:12 +03:00
|
|
|
public sealed class PunishmentOption : GuildOption<string>
|
2024-04-08 16:38:03 +03:00
|
|
|
{
|
|
|
|
private static readonly List<string> AllowedValues =
|
|
|
|
[
|
|
|
|
"ban", "kick", "mute", "off", "disable", "disabled"
|
|
|
|
];
|
|
|
|
|
|
|
|
public PunishmentOption(string name, string defaultValue) : base(name, defaultValue) { }
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override Result Set(JsonNode settings, string from)
|
|
|
|
{
|
|
|
|
return AllowedValues.Contains(from.ToLowerInvariant())
|
|
|
|
? base.Set(settings, from.ToLowerInvariant())
|
|
|
|
: new ArgumentInvalidError(nameof(from), Messages.InvalidWarnPunishment);
|
|
|
|
}
|
|
|
|
}
|