diff --git a/src/NadekoBot/Modules/Administration/Administration.cs b/src/NadekoBot/Modules/Administration/Administration.cs index 22271255..c75525bf 100644 --- a/src/NadekoBot/Modules/Administration/Administration.cs +++ b/src/NadekoBot/Modules/Administration/Administration.cs @@ -37,8 +37,6 @@ namespace NadekoBot.Modules.Administration { _log = LogManager.GetCurrentClassLogger(); NadekoBot.CommandHandler.CommandExecuted += DelMsgOnCmd_Handler; - - } private static async Task DelMsgOnCmd_Handler(IUserMessage msg, Command cmd) diff --git a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 0546837a..53a22763 100644 --- a/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/src/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -12,6 +12,8 @@ using NadekoBot.Services.Database.Models; using System.Linq; using NadekoBot.Extensions; using System.Threading; +using System.Diagnostics; +using NLog; namespace NadekoBot.Modules.ClashOfClans { @@ -22,8 +24,12 @@ namespace NadekoBot.Modules.ClashOfClans private static Timer checkWarTimer { get; } + private static new readonly Logger _log; + static ClashOfClans() { + _log = LogManager.GetCurrentClassLogger(); + var sw = Stopwatch.StartNew(); using (var uow = DbHandler.UnitOfWork()) { ClashWars = new ConcurrentDictionary>( @@ -50,6 +56,9 @@ namespace NadekoBot.Modules.ClashOfClans } } }, null, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1)); + + sw.Stop(); + _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s"); } private static async Task CheckWar(TimeSpan callExpire, ClashWar war) diff --git a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs index ed1224e3..dfbe7dc1 100644 --- a/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/src/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -7,6 +7,8 @@ using System.Collections.Concurrent; using NadekoBot.Services.Database.Models; using Discord; using NadekoBot.Extensions; +using NLog; +using System.Diagnostics; namespace NadekoBot.Modules.CustomReactions { @@ -18,14 +20,20 @@ namespace NadekoBot.Modules.CustomReactions public static ConcurrentDictionary ReactionStats { get; } = new ConcurrentDictionary(); + private static new readonly Logger _log; + static CustomReactions() { + _log = LogManager.GetCurrentClassLogger(); + var sw = Stopwatch.StartNew(); using (var uow = DbHandler.UnitOfWork()) { var items = uow.CustomReactions.GetAll(); GuildReactions = new ConcurrentDictionary>(items.Where(g => g.GuildId != null && g.GuildId != 0).GroupBy(k => k.GuildId.Value).ToDictionary(g => g.Key, g => new ConcurrentHashSet(g))); GlobalReactions = new ConcurrentHashSet(items.Where(g => g.GuildId == null || g.GuildId == 0)); } + sw.Stop(); + _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s"); } public CustomReactions() : base() { diff --git a/src/NadekoBot/Modules/Gambling/Gambling.cs b/src/NadekoBot/Modules/Gambling/Gambling.cs index efd0f1fa..f1ae8ad1 100644 --- a/src/NadekoBot/Modules/Gambling/Gambling.cs +++ b/src/NadekoBot/Modules/Gambling/Gambling.cs @@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Gambling public static string CurrencyPluralName { get; set; } public static string CurrencySign { get; set; } - public Gambling() : base() + static Gambling() { using (var uow = DbHandler.UnitOfWork()) { diff --git a/src/NadekoBot/Modules/Games/Games.cs b/src/NadekoBot/Modules/Games/Games.cs index 8272598a..021e070b 100644 --- a/src/NadekoBot/Modules/Games/Games.cs +++ b/src/NadekoBot/Modules/Games/Games.cs @@ -21,9 +21,7 @@ namespace NadekoBot.Modules.Games } } } - public Games() : base() - { - } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] diff --git a/src/NadekoBot/Modules/Help/Help.cs b/src/NadekoBot/Modules/Help/Help.cs index f1f1ea0e..127eeeb2 100644 --- a/src/NadekoBot/Modules/Help/Help.cs +++ b/src/NadekoBot/Modules/Help/Help.cs @@ -22,6 +22,8 @@ namespace NadekoBot.Modules.Help static Help() { + + //todo don't cache this, just query db when someone wants -h using (var uow = DbHandler.UnitOfWork()) { var config = uow.BotConfig.GetOrCreate(); diff --git a/src/NadekoBot/ShardedDiscordClient.cs b/src/NadekoBot/ShardedDiscordClient.cs index 59ad695d..738f2007 100644 --- a/src/NadekoBot/ShardedDiscordClient.cs +++ b/src/NadekoBot/ShardedDiscordClient.cs @@ -91,15 +91,17 @@ namespace NadekoBot internal Task LoginAsync(TokenType tokenType, string token) => Task.WhenAll(Clients.Select(async c => { await c.LoginAsync(tokenType, token).ConfigureAwait(false); _log.Info($"Shard #{c.ShardId} logged in."); })); - internal Task ConnectAsync() => - Task.WhenAll(Clients.Select(async c => + internal async Task ConnectAsync() + { + + foreach (var c in Clients) { try { var sw = Stopwatch.StartNew(); await c.ConnectAsync().ConfigureAwait(false); sw.Stop(); - _log.Info($"Shard #{c.ShardId} connected after {sw.Elapsed.TotalSeconds}s ({++_connectedCount}/{Clients.Count})"); + _log.Info($"Shard #{c.ShardId} connected after {sw.Elapsed.TotalSeconds:F2}s ({++_connectedCount}/{Clients.Count})"); } catch { @@ -111,7 +113,8 @@ namespace NadekoBot _log.Error(ex2); } } - })); + } + } internal Task DownloadAllUsersAsync() => Task.WhenAll(Clients.Select(async c => @@ -119,7 +122,7 @@ namespace NadekoBot var sw = Stopwatch.StartNew(); await c.DownloadAllUsersAsync().ConfigureAwait(false); sw.Stop(); - _log.Info($"Shard #{c.ShardId} downloaded {c.GetGuilds().Sum(g => g.GetUsers().Count)} users after {sw.Elapsed.TotalSeconds}s ({++_downloadedCount}/{Clients.Count})."); + _log.Info($"Shard #{c.ShardId} downloaded {c.GetGuilds().Sum(g => g.GetUsers().Count)} users after {sw.Elapsed.TotalSeconds:F2}s ({++_downloadedCount}/{Clients.Count})."); })); public async Task SetGame(string game)