Added some logging, slight changes and fixed music thumbnail
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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<ulong, List<ClashWar>>(
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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<string, uint> ReactionStats { get; } = new ConcurrentDictionary<string, uint>();
 | 
			
		||||
 | 
			
		||||
        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<ulong, ConcurrentHashSet<CustomReaction>>(items.Where(g => g.GuildId != null && g.GuildId != 0).GroupBy(k => k.GuildId.Value).ToDictionary(g => g.Key, g => new ConcurrentHashSet<CustomReaction>(g)));
 | 
			
		||||
                GlobalReactions = new ConcurrentHashSet<CustomReaction>(items.Where(g => g.GuildId == null || g.GuildId == 0));
 | 
			
		||||
            }
 | 
			
		||||
            sw.Stop();
 | 
			
		||||
            _log.Debug($"Loaded in {sw.Elapsed.TotalSeconds:F2}s");
 | 
			
		||||
        }
 | 
			
		||||
        public CustomReactions() : base()
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -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())
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -21,9 +21,7 @@ namespace NadekoBot.Modules.Games
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public Games() : base()
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        [NadekoCommand, Usage, Description, Aliases]
 | 
			
		||||
        [RequireContext(ContextType.Guild)]
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 
 | 
			
		||||
@@ -71,11 +71,11 @@ namespace NadekoBot.Modules.Music.Classes
 | 
			
		||||
                switch (SongInfo.ProviderType)
 | 
			
		||||
                {
 | 
			
		||||
                    case MusicType.Radio:
 | 
			
		||||
                        return $"https://cdn.discordapp.com/attachments/155726317222887425/261850925063340032/1482522097_radio.png"; //test links
 | 
			
		||||
                    case MusicType.Normal:
 | 
			
		||||
                        //todo have videoid in songinfo from the start
 | 
			
		||||
                        var videoId = Regex.Match(SongInfo.Query, "<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+");
 | 
			
		||||
                        return $"https://img.youtube.com/vi/{ videoId }/0.jpg";
 | 
			
		||||
                    case MusicType.Normal:
 | 
			
		||||
                        return $"https://cdn.discordapp.com/attachments/155726317222887425/261850925063340032/1482522097_radio.png"; //test links
 | 
			
		||||
                    case MusicType.Local:
 | 
			
		||||
                        return $"https://cdn.discordapp.com/attachments/155726317222887425/261850914783100928/1482522077_music.png"; //test links
 | 
			
		||||
                    case MusicType.Soundcloud:
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user