mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 17:19:00 +03:00
24 lines
693 B
C#
24 lines
693 B
C#
|
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);
|
||
|
}
|
||
|
}
|