more cleanup, 1 more commit before being prod ready
This commit is contained in:
@ -7,13 +7,10 @@ using NadekoBot.Extensions;
|
||||
using System.Threading.Tasks;
|
||||
using NadekoBot.Commands;
|
||||
using System.IO;
|
||||
using System.Collections.Concurrent;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using NadekoBot.Classes;
|
||||
using NadekoBot.Classes.Permissions;
|
||||
using NadekoBot.Classes._DataModels;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace NadekoBot.Modules {
|
||||
internal class Administration : DiscordModule {
|
||||
@ -178,20 +175,10 @@ namespace NadekoBot.Modules {
|
||||
await usr.Server.Ban(usr);
|
||||
await e.Channel.SendMessage("Banned user " + usr.Name + " Id: " + usr.Id);
|
||||
}
|
||||
} catch (Exception ex) { }
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".ub").Alias(".unban")
|
||||
.Parameter("everything", ParameterType.Unparsed)
|
||||
.Description("Unbans a mentioned user.")
|
||||
.Do(async e => {
|
||||
try {
|
||||
if (e.User.ServerPermissions.BanMembers && e.Message.MentionedUsers.Any()) {
|
||||
var usr = e.Message.MentionedUsers.First();
|
||||
await usr.Server.Unban(usr);
|
||||
await e.Channel.SendMessage("Unbanned user " + usr.Name + " Id: " + usr.Id);
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cgb.CreateCommand(".k").Alias(".kick")
|
||||
@ -389,15 +376,6 @@ namespace NadekoBot.Modules {
|
||||
var heap = Task.Run(() => NadekoStats.Instance.Heap());
|
||||
await e.Channel.SendMessage($"`Heap Size:` {heap}");
|
||||
});
|
||||
|
||||
/*
|
||||
cgb.CreateCommand(".leaveall")
|
||||
.Description("Nadeko leaves all servers **OWNER ONLY**")
|
||||
.Do(e => {
|
||||
if (NadekoBot.IsOwner(e.User.Id))
|
||||
NadekoBot.client.Servers.ForEach(async s => { if (s.Name == e.Server.Name) return; await s.Leave(); });
|
||||
});
|
||||
*/
|
||||
cgb.CreateCommand(".prune")
|
||||
.Parameter("num", ParameterType.Required)
|
||||
.Description("Prunes a number of messages from the current channel.\n**Usage**: .prune 5")
|
||||
|
@ -4,7 +4,6 @@ using Discord.Modules;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
|
@ -6,7 +6,7 @@ using NadekoBot.Commands;
|
||||
namespace NadekoBot.Modules {
|
||||
internal class Help : DiscordModule {
|
||||
|
||||
public Help() {
|
||||
public Help() {
|
||||
commands.Add(new HelpCommand());
|
||||
}
|
||||
|
||||
@ -27,13 +27,14 @@ 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.GetService<CommandService>().AllCommands
|
||||
var cmds = NadekoBot.Client.GetService<CommandService>().AllCommands
|
||||
.Where(c => c.Category.ToLower() == e.GetArg("module").Trim().ToLower());
|
||||
if (commands == null || commands.Count() == 0) {
|
||||
var cmdsArray = cmds as Command[] ?? cmds.ToArray();
|
||||
if (!cmdsArray.Any()) {
|
||||
await e.Channel.SendMessage("That module does not exist.");
|
||||
return;
|
||||
}
|
||||
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", commands.Select(c => c.Text)));
|
||||
await e.Channel.SendMessage("`List of commands:` \n• " + string.Join("\n• ", cmdsArray.Select(c => c.Text)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -6,9 +6,11 @@ using Manatee.Trello.ManateeJson;
|
||||
using Manatee.Trello;
|
||||
using System.Timers;
|
||||
using NadekoBot.Extensions;
|
||||
using Action = Manatee.Trello.Action;
|
||||
|
||||
namespace NadekoBot.Modules {
|
||||
internal class Trello : DiscordModule {
|
||||
private readonly Timer t = new Timer() { Interval = 2000 };
|
||||
public override void Install(ModuleManager manager) {
|
||||
|
||||
var client = manager.Client;
|
||||
@ -24,8 +26,6 @@ namespace NadekoBot.Modules {
|
||||
Discord.Channel bound = null;
|
||||
Board board = null;
|
||||
|
||||
Timer t = new Timer();
|
||||
t.Interval = 2000;
|
||||
List<string> last5ActionIDs = null;
|
||||
t.Elapsed += async (s, e) => {
|
||||
try {
|
||||
@ -33,31 +33,26 @@ namespace NadekoBot.Modules {
|
||||
return; //do nothing if there is no bound board
|
||||
|
||||
board.Refresh();
|
||||
IEnumerable<Manatee.Trello.Action> cur5Actions;
|
||||
if (board.Actions.Count() < 5)
|
||||
cur5Actions = board.Actions.Take(board.Actions.Count());
|
||||
else
|
||||
cur5Actions = board.Actions.Take(5);
|
||||
var cur5Actions = board.Actions.Take(board.Actions.Count() < 5 ? board.Actions.Count() : 5);
|
||||
var cur5ActionsArray = cur5Actions as Action[] ?? cur5Actions.ToArray();
|
||||
|
||||
if (last5ActionIDs == null) {
|
||||
last5ActionIDs = new List<string>();
|
||||
foreach (var a in cur5Actions)
|
||||
last5ActionIDs.Add(a.Id);
|
||||
last5ActionIDs = cur5ActionsArray.Select(a => a.Id).ToList();
|
||||
return;
|
||||
}
|
||||
foreach (var a in cur5Actions.Where(ca => !last5ActionIDs.Contains(ca.Id))) {
|
||||
|
||||
foreach (var a in cur5ActionsArray.Where(ca => !last5ActionIDs.Contains(ca.Id))) {
|
||||
await bound.Send("**--TRELLO NOTIFICATION--**\n" + a.ToString());
|
||||
}
|
||||
last5ActionIDs.Clear();
|
||||
foreach (var a in cur5Actions)
|
||||
last5ActionIDs.Add(a.Id);
|
||||
last5ActionIDs.AddRange(cur5ActionsArray.Select(a => a.Id));
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine("Timer failed " + ex.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
manager.CreateCommands("", cgb => {
|
||||
|
||||
manager.CreateCommands("trello ", cgb => {
|
||||
|
||||
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
|
||||
|
||||
cgb.CreateCommand("join")
|
||||
@ -124,7 +119,7 @@ namespace NadekoBot.Modules {
|
||||
if (success && num <= board.Lists.Count() && num > 0)
|
||||
list = board.Lists[num - 1];
|
||||
else
|
||||
list = board.Lists.Where(l => l.Name == e.GetArg("list_name")).FirstOrDefault();
|
||||
list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
|
||||
|
||||
|
||||
if (list != null)
|
||||
|
Reference in New Issue
Block a user