new libs, prune is back, fixed conversation perms, fixed "general"

This commit is contained in:
Master Kwoth
2016-02-14 00:57:52 +01:00
parent ca52c29559
commit 5fbd4c9f1a
13 changed files with 26 additions and 17 deletions

@ -166,7 +166,7 @@ namespace NadekoBot.Modules {
.Description("List all of the bot's commands from a certain module.")
.Parameter("module", ParameterType.Unparsed)
.Do(async e => {
var commands = NadekoBot.client.Commands().AllCommands
var commands = NadekoBot.client.Services.Get<CommandService>().AllCommands
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
if (commands == null || commands.Count() == 0) {
await e.Send("That module does not exist.");
@ -403,8 +403,14 @@ namespace NadekoBot.Modules {
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
.Do(async e => {
if (!e.User.ServerPermissions.ManageMessages) return;
int val;
if (string.IsNullOrWhiteSpace(e.GetArg("num")) || !int.TryParse(e.GetArg("num"), out val) || val < 0)
return;
await e.Send("This feature is being reconstructed.");
foreach (var msg in await e.Channel.DownloadMessages(val)) {
await msg.Delete();
await Task.Delay(100);
}
});
cgb.CreateCommand(".die")

@ -47,6 +47,8 @@ namespace NadekoBot.Modules {
manager.CreateCommands(NadekoBot.botMention, cgb => {
var client = manager.Client;
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
commands.ForEach(cmd => cmd.Init(cgb));
cgb.CreateCommand("uptime")

@ -312,7 +312,7 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetServerCommandPermission(e.Server, command.Text, state);
}
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** on this server.");
@ -353,7 +353,7 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
Discord.Channel channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetChannelCommandPermission(channel, command.Text, state);
}
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.");
@ -394,7 +394,7 @@ namespace NadekoBot.Modules {
bool state = PermissionHelper.ValidateBool(e.GetArg("bool"));
string module = PermissionHelper.ValidateModule(e.GetArg("module"));
Discord.Role role = PermissionHelper.ValidateRole(e.Server, e.GetArg("channel"));
foreach (var command in NadekoBot.client.Commands().AllCommands.Where(c => c.Category == module)) {
foreach (var command in NadekoBot.client.Services.Get<CommandService>().AllCommands.Where(c => c.Category == module)) {
PermsHandler.SetRoleCommandPermission(role, command.Text, state);
}
await e.Send($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.");