RegexBot/Modules/ModLogs/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

22 lines
No EOL
835 B
C#

using RegexBot.Common;
namespace RegexBot.Modules.ModLogs;
class ModuleConfig {
public EntityName ReportingChannel { get; }
public bool LogMessageDeletions { get; }
public bool LogMessageEdits { get; }
public ModuleConfig(JObject config) {
const string RptChError = $"'{nameof(ReportingChannel)}' must be set to a valid channel name.";
try {
ReportingChannel = new EntityName(config[nameof(ReportingChannel)]?.Value<string>()!, EntityType.Channel);
} catch (Exception) {
throw new ModuleLoadException(RptChError);
}
// Individual logging settings - all default to false
LogMessageDeletions = config[nameof(LogMessageDeletions)]?.Value<bool>() ?? false;
LogMessageEdits = config[nameof(LogMessageEdits)]?.Value<bool>() ?? false;
}
}