more cleanup, 1 more commit before being prod ready
This commit is contained in:
		| @@ -1,10 +1,7 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
|  | ||||
| namespace NadekoBot.Classes.JSONModels { | ||||
|     internal class Config { | ||||
|     internal class LocalizedStrings { | ||||
|         public string[] _8BallAnswers { get; set; } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -26,7 +26,6 @@ namespace NadekoBot { | ||||
|         private NadekoStats() { | ||||
|             var commandService = NadekoBot.Client.GetService<CommandService>(); | ||||
|  | ||||
|             statsStopwatch = new Stopwatch(); | ||||
|             statsStopwatch.Start(); | ||||
|             commandService.CommandExecuted += StatsCollector_RanCommand; | ||||
|  | ||||
| @@ -44,16 +43,14 @@ namespace NadekoBot { | ||||
|                     ServerCount++; | ||||
|                     TextChannelsCount += e.Server.TextChannels.Count(); | ||||
|                     VoiceChannelsCount += e.Server.VoiceChannels.Count(); | ||||
|                 } | ||||
|                 catch { } | ||||
|                 } catch { } | ||||
|             }; | ||||
|             NadekoBot.Client.LeftServer += (s, e) => { | ||||
|                 try { | ||||
|                     ServerCount--; | ||||
|                     TextChannelsCount -= e.Server.TextChannels.Count(); | ||||
|                     VoiceChannelsCount -= e.Server.VoiceChannels.Count(); | ||||
|                 } | ||||
|                 catch { } | ||||
|                 } catch { } | ||||
|             }; | ||||
|             NadekoBot.Client.ChannelCreated += (s, e) => { | ||||
|                 try { | ||||
| @@ -63,8 +60,7 @@ namespace NadekoBot { | ||||
|                         TextChannelsCount++; | ||||
|                     else if (e.Channel.Type == ChannelType.Voice) | ||||
|                         VoiceChannelsCount++; | ||||
|                 } | ||||
|                 catch { } | ||||
|                 } catch { } | ||||
|             }; | ||||
|             NadekoBot.Client.ChannelDestroyed += (s, e) => { | ||||
|                 try { | ||||
| @@ -74,8 +70,7 @@ namespace NadekoBot { | ||||
|                         VoiceChannelsCount++; | ||||
|                     else if (e.Channel.Type == ChannelType.Voice) | ||||
|                         VoiceChannelsCount--; | ||||
|                 } | ||||
|                 catch { } | ||||
|                 } catch { } | ||||
|             }; | ||||
|         } | ||||
|  | ||||
| @@ -129,8 +124,7 @@ namespace NadekoBot { | ||||
|                         ConnectedServers = connectedServers, | ||||
|                         DateAdded = DateTime.Now | ||||
|                     }); | ||||
|                 } | ||||
|                 catch { | ||||
|                 } catch { | ||||
|                     Console.WriteLine("DB Exception in stats collecting."); | ||||
|                     break; | ||||
|                 } | ||||
| @@ -142,17 +136,16 @@ namespace NadekoBot { | ||||
|                 try { | ||||
|                     commandsRan++; | ||||
|                     Classes.DbHandler.Instance.InsertData(new Classes._DataModels.Command { | ||||
|                         ServerId = (long) e.Server.Id, | ||||
|                         ServerId = (long)e.Server.Id, | ||||
|                         ServerName = e.Server.Name, | ||||
|                         ChannelId = (long) e.Channel.Id, | ||||
|                         ChannelId = (long)e.Channel.Id, | ||||
|                         ChannelName = e.Channel.Name, | ||||
|                         UserId = (long) e.User.Id, | ||||
|                         UserId = (long)e.User.Id, | ||||
|                         UserName = e.User.Name, | ||||
|                         CommandName = e.Command.Text, | ||||
|                         DateAdded = DateTime.Now | ||||
|                     }); | ||||
|                 } | ||||
|                 catch { | ||||
|                 } catch { | ||||
|                     Console.WriteLine("Error in ran command DB write."); | ||||
|                 } | ||||
|             }); | ||||
|   | ||||
| @@ -4,7 +4,6 @@ using System.Collections.Concurrent; | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Threading; | ||||
| using System.Threading.Tasks; | ||||
| using Discord.Commands; | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,6 @@ using System.IO; | ||||
| using System.Linq; | ||||
| using System.Net; | ||||
| using System.Net.Http; | ||||
| using System.Net.Http.Headers; | ||||
| using System.Security.Authentication; | ||||
| using System.Text.RegularExpressions; | ||||
| using System.Threading.Tasks; | ||||
|   | ||||
| @@ -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) | ||||
|   | ||||
| @@ -6,11 +6,9 @@ using Discord.Commands; | ||||
| using NadekoBot.Modules; | ||||
| using Discord.Modules; | ||||
| using Discord.Audio; | ||||
| using System.Timers; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using NadekoBot.Classes; | ||||
| using NadekoBot.Classes.JSONModels; | ||||
| using NadekoBot.Commands; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user