public Task <Result> Execute(CommandMetadata metadata, string pluginName) { ParentPlugin.AddPlugin(pluginName); if (ParentPlugin.GuildHandler.Plugins.IsPluginActive(pluginName)) { return(TaskResult(null, $"Succesfully enabled plugin '{Plugin.GetFullName(PluginLoader.GetPlugin(pluginName))}' in this server.")); } else { return(TaskResult(null, $"Failed to add plugin '{pluginName}'. An error may have occured in its initialization.")); } }
public async Task <Result> Execute(CommandMetadata metadata, string pluginName) { Type plugin = PluginLoader.GetPlugin(pluginName); if (plugin != null) { string name = Plugin.GetName(plugin); if (!ParentPlugin.GuildHandler.Plugins.IsPluginActive(pluginName)) { QuestionMessage question = new QuestionMessage($"Are you sure you wish to enable plugin '{name}'?", async() => { ParentPlugin.AddPlugin(pluginName); if (ParentPlugin.GuildHandler.Plugins.IsPluginActive(pluginName)) { var state = ParentPlugin.GuildHandler.State; await metadata.Message.Channel.SendMessageAsync(string.Empty, false, state.ChangesToEmbed($"Succesfully enabled plugin '{name}' on this server.")); } else { IEnumerable <string> exceptions = ParentPlugin.GuildHandler.Plugins.GetInitializationExceptions().Select(x => x.InnerException.Message); await metadata.Message.Channel.SendMessageAsync($"Failed to add plugin '{name}'. Issues occured during initialization:\n\t{string.Join("\n\t", exceptions)}"); } }, async() => await metadata.Message.Channel.SendMessageAsync($"Cancelled enabled plugin '{name}'.")).SetRecipient(metadata.AuthorID); await metadata.Message.Channel.SendMessageAsync(null, false, GetModuleEmbed(PluginLoader.GetPlugin(pluginName))); return(new Result(question, string.Empty)); } else { return(new Result(null, $"Failed to enable plugin: '{name}' is already enabled.")); } } else { return(new Result(null, $"Failed to enable plugin: No available plugins matches '{pluginName}' Check `!plugin available` to get a list of available plugins.")); } }