1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-01-31 17:19:00 +03:00
Octobot/src/Data/Options/PunishmentOption.cs

24 lines
693 B
C#
Raw Normal View History

using System.Text.Json.Nodes;
using Remora.Results;
namespace Octobot.Data.Options;
/// <inheritdoc />
public sealed class PunishmentOption : Option<string>
{
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);
}
}