diff --git a/BotModule.cs b/BotModule.cs
index 6e1540c..7983dca 100644
--- a/BotModule.cs
+++ b/BotModule.cs
@@ -13,8 +13,8 @@ namespace Noikoio.RegexBot
{
private readonly DiscordSocketClient _client;
private readonly AsyncLogger _logger;
-
- public abstract string Name { get; }
+
+ public string Name => this.GetType().Name;
protected DiscordSocketClient Client => _client;
public BotModule(DiscordSocketClient client)
@@ -80,25 +80,4 @@ namespace Noikoio.RegexBot
public sealed override int GetHashCode() => base.GetHashCode();
public sealed override string ToString() => base.ToString();
}
-
- ///
- /// Indicates which section under an individual Discord guild configuration should be passed to the
- /// module's method during configuration load.
- ///
- [AttributeUsage(AttributeTargets.Method, Inherited = false)]
- public class ConfigSectionAttribute : Attribute
- {
- private readonly string _sectionName;
-
- public string SectionName => _sectionName;
-
- public ConfigSectionAttribute(string sectionName)
- {
- if (string.IsNullOrWhiteSpace(sectionName))
- {
- throw new ArgumentNullException("Configuration section name cannot be blank.");
- }
- _sectionName = sectionName;
- }
- }
}
diff --git a/Configuration.cs b/Configuration.cs
index 6592ee5..f371e6c 100644
--- a/Configuration.cs
+++ b/Configuration.cs
@@ -162,16 +162,12 @@ namespace Noikoio.RegexBot
Dictionary customConfs = new Dictionary();
foreach (var item in _bot.Modules)
{
- var attr = item.GetType().GetTypeInfo()
- .GetMethod("ProcessConfiguration").GetCustomAttribute();
- if (attr == null)
- {
- await SLog("No additional configuration for " + item.Name);
- continue;
- }
- var section = sconf[attr.SectionName];
+ var confSection = item.Name;
+
+ var section = sconf[confSection];
if (section == null)
{
+ // Section not in config. Do not call loader method.
await SLog("Additional configuration not defined for " + item.Name);
continue;
}
@@ -191,8 +187,7 @@ namespace Noikoio.RegexBot
customConfs.Add(item, result);
}
-
- // Switch to using new data
+ // Switch to new configuration
List> rulesfinal = new List>();
newservers.Add(new ServerConfig(sid, mods, new ReadOnlyDictionary(customConfs)));
}
diff --git a/EntityCache/Module.cs b/EntityCache/Module.cs
index 0a4da61..c4945ab 100644
--- a/EntityCache/Module.cs
+++ b/EntityCache/Module.cs
@@ -15,8 +15,6 @@ namespace Noikoio.RegexBot.EntityCache
{
private readonly DatabaseConfig _db;
- public override string Name => nameof(EntityCache);
-
public Module(DiscordSocketClient client) : base(client)
{
if (RegexBot.Config.DatabaseAvailable)
diff --git a/Module/AutoMod/AutoMod.cs b/Module/AutoMod/AutoMod.cs
index b6158cb..88c4b14 100644
--- a/Module/AutoMod/AutoMod.cs
+++ b/Module/AutoMod/AutoMod.cs
@@ -16,15 +16,12 @@ namespace Noikoio.RegexBot.Module.AutoMod
///
class AutoMod : BotModule
{
- public override string Name => "AutoMod";
-
public AutoMod(DiscordSocketClient client) : base(client)
{
client.MessageReceived += CMessageReceived;
client.MessageUpdated += CMessageUpdated;
}
-
- [ConfigSection("automod")]
+
public override async Task