diff --git a/src/Discord.Net.Commands/CommandBuilder.cs b/src/Discord.Net.Commands/CommandBuilder.cs
index 731445efd..aca8dd46b 100644
--- a/src/Discord.Net.Commands/CommandBuilder.cs
+++ b/src/Discord.Net.Commands/CommandBuilder.cs
@@ -113,7 +113,7 @@ namespace Discord.Commands
}
var command = new Command(text);
command.MinPerms = _defaultMinPermissions;
- _plugin._commands.Add(command);
+ _plugin.AddCommand(command);
return new CommandBuilder(command);
}
}
diff --git a/src/Discord.Net.Commands/CommandsPlugin.cs b/src/Discord.Net.Commands/CommandsPlugin.cs
index a238c1645..f35f0a60d 100644
--- a/src/Discord.Net.Commands/CommandsPlugin.cs
+++ b/src/Discord.Net.Commands/CommandsPlugin.cs
@@ -6,7 +6,8 @@ namespace Discord.Commands
/// A Discord.Net client with extensions for handling common bot operations like text commands.
public partial class CommandsPlugin
{
- internal List _commands;
+ private readonly DiscordClient _client;
+ private List _commands;
private Func _getPermissions;
public IEnumerable Commands => _commands;
@@ -16,8 +17,9 @@ namespace Discord.Commands
public bool RequireCommandCharInPublic { get; set; }
public bool RequireCommandCharInPrivate { get; set; }
- public CommandsPlugin(Func getPermissions = null)
+ public CommandsPlugin(DiscordClient client, Func getPermissions = null)
{
+ _client = client;
_getPermissions = getPermissions;
_commands = new List();
@@ -25,10 +27,7 @@ namespace Discord.Commands
UseCommandChar = false;
RequireCommandCharInPublic = true;
RequireCommandCharInPrivate = true;
- }
- public void Install(DiscordClient client)
- {
client.MessageCreated += async (s, e) =>
{
//If commands aren't being used, don't bother processing them
@@ -123,5 +122,10 @@ namespace Discord.Commands
_commands.Add(command);
return new CommandBuilder(command);
}
- }
+
+ internal void AddCommand(Command command)
+ {
+ _commands.Add(command);
+ }
+ }
}