RegexBot/Modules/PendingOutRole/ModuleConfig.cs
Noi 7b29753290 Update entity classes
EntityList's `enforceTypes` setting was removed, as EntityName
enforced entries being unambiguous anyway.
Added a way to enforce specific types on instantiation or else
throw an exception, and updated all existing uses requiring that
check accordingly.
2022-08-22 21:14:09 -07:00

17 lines
557 B
C#

using RegexBot.Common;
namespace RegexBot.Modules.PendingOutRole;
class ModuleConfig {
public EntityName Role { get; }
public ModuleConfig(JObject conf) {
try {
Role = new EntityName(conf[nameof(Role)]?.Value<string>()!, EntityType.Role);
} catch (ArgumentException) {
throw new ModuleLoadException("Role was not properly specified.");
} catch (FormatException) {
throw new ModuleLoadException("Name specified in configuration is not a role.");
}
}
}