a few speedtyping fixes, some music experimentation
This commit is contained in:
		@@ -116,7 +116,7 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                    if (msg == null)
 | 
					                    if (msg == null)
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (this.Channel == null || this.Channel.Id != this.Channel.Id) return;
 | 
					                    if (this.Channel == null || this.Channel.Id != msg.Channel.Id) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    var guess = msg.Content;
 | 
					                    var guess = msg.Content;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -127,10 +127,10 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                        var wpm = CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60;
 | 
					                        var wpm = CurrentSentence.Length / WORD_VALUE / sw.Elapsed.Seconds * 60;
 | 
				
			||||||
                        finishedUserIds.Add(msg.Author.Id);
 | 
					                        finishedUserIds.Add(msg.Author.Id);
 | 
				
			||||||
                        await this.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
 | 
					                        await this.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
 | 
				
			||||||
                            .WithTitle((string)$"{msg.Author} finished the race!")
 | 
					                            .WithTitle($"{msg.Author} finished the race!")
 | 
				
			||||||
                            .AddField(efb => efb.WithName("Place").WithValue($"#{finishedUserIds.Count}").WithIsInline(true))
 | 
					                            .AddField(efb => efb.WithName("Place").WithValue($"#{finishedUserIds.Count}").WithIsInline(true))
 | 
				
			||||||
                            .AddField(efb => efb.WithName("WPM").WithValue($"{wpm:F2} *[{sw.Elapsed.Seconds.ToString()}sec]*").WithIsInline(true))
 | 
					                            .AddField(efb => efb.WithName("WPM").WithValue($"{wpm:F2} *[{sw.Elapsed.TotalSeconds:F2}sec]*").WithIsInline(true))
 | 
				
			||||||
                            .AddField(efb => efb.WithName((string)"Errors").WithValue((string)distance.ToString()).WithIsInline((bool)true)))
 | 
					                            .AddField(efb => efb.WithName("Errors").WithValue(distance.ToString()).WithIsInline(true)))
 | 
				
			||||||
                                .ConfigureAwait(false);
 | 
					                                .ConfigureAwait(false);
 | 
				
			||||||
                        if (finishedUserIds.Count % 4 == 0)
 | 
					                        if (finishedUserIds.Count % 4 == 0)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
@@ -150,11 +150,11 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            public static List<TypingArticle> TypingArticles { get; } = new List<TypingArticle>();
 | 
					            public static List<TypingArticle> TypingArticles { get; } = new List<TypingArticle>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const string typingArticlesPath = "data/typing_articles.json";
 | 
					            private const string _typingArticlesPath = "data/typing_articles.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            static SpeedTypingCommands()
 | 
					            static SpeedTypingCommands()
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try { TypingArticles = JsonConvert.DeserializeObject<List<TypingArticle>>(File.ReadAllText(typingArticlesPath)); } catch { }
 | 
					                try { TypingArticles = JsonConvert.DeserializeObject<List<TypingArticle>>(File.ReadAllText(_typingArticlesPath)); } catch { }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            public static ConcurrentDictionary<ulong, TypingGame> RunningContests = new ConcurrentDictionary<ulong, TypingGame>();
 | 
					            public static ConcurrentDictionary<ulong, TypingGame> RunningContests = new ConcurrentDictionary<ulong, TypingGame>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -207,7 +207,7 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                    Text = text.SanitizeMentions(),
 | 
					                    Text = text.SanitizeMentions(),
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
 | 
					                File.WriteAllText(_typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                await channel.SendConfirmAsync("Added new article for typing game.").ConfigureAwait(false);
 | 
					                await channel.SendConfirmAsync("Added new article for typing game.").ConfigureAwait(false);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -221,7 +221,7 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                if (page < 1)
 | 
					                if (page < 1)
 | 
				
			||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                var articles = TypingArticles.Skip((page - 1) * 15).Take(15);
 | 
					                var articles = TypingArticles.Skip((page - 1) * 15).Take(15).ToArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!articles.Any())
 | 
					                if (!articles.Any())
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
@@ -229,7 +229,7 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                    return;
 | 
					                    return;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                var i = (page - 1) * 15;
 | 
					                var i = (page - 1) * 15;
 | 
				
			||||||
                await channel.SendConfirmAsync("List of articles for Type Race", String.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")))
 | 
					                await channel.SendConfirmAsync("List of articles for Type Race", string.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}")))
 | 
				
			||||||
                             .ConfigureAwait(false);
 | 
					                             .ConfigureAwait(false);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -247,7 +247,7 @@ namespace NadekoBot.Modules.Games
 | 
				
			|||||||
                var removed = TypingArticles[index];
 | 
					                var removed = TypingArticles[index];
 | 
				
			||||||
                TypingArticles.RemoveAt(index);
 | 
					                TypingArticles.RemoveAt(index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
 | 
					                File.WriteAllText(_typingArticlesPath, JsonConvert.SerializeObject(TypingArticles));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                await channel.SendConfirmAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}")
 | 
					                await channel.SendConfirmAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}")
 | 
				
			||||||
                             .ConfigureAwait(false);
 | 
					                             .ConfigureAwait(false);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,14 +129,10 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
                while (!Destroyed)
 | 
					                while (!Destroyed)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    try
 | 
					                    try
 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        if (audioClient?.ConnectionState != ConnectionState.Connected)
 | 
					 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if (audioClient != null)
 | 
					                        if (audioClient != null)
 | 
				
			||||||
                            try { await audioClient.DisconnectAsync().ConfigureAwait(false); } catch { }
 | 
					                            try { await audioClient.DisconnectAsync().ConfigureAwait(false); } catch { }
 | 
				
			||||||
                        audioClient = await PlaybackVoiceChannel.ConnectAsync().ConfigureAwait(false);
 | 
					                        audioClient = await PlaybackVoiceChannel.ConnectAsync().ConfigureAwait(false);
 | 
				
			||||||
                            continue;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        CurrentSong = GetNextSong();
 | 
					                        CurrentSong = GetNextSong();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -313,9 +309,13 @@ namespace NadekoBot.Modules.Music.Classes
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var curSong = CurrentSong;
 | 
					            var curSong = CurrentSong;
 | 
				
			||||||
            var toUpdate = playlist.Where(s => s.SongInfo.ProviderType == MusicType.Normal &&
 | 
					            var toUpdate = playlist.Where(s => s.SongInfo.ProviderType == MusicType.Normal &&
 | 
				
			||||||
                                                            s.TotalTime == TimeSpan.Zero);
 | 
					                                                            s.TotalTime == TimeSpan.Zero)
 | 
				
			||||||
 | 
					                                                            .ToArray();
 | 
				
			||||||
            if (curSong != null)
 | 
					            if (curSong != null)
 | 
				
			||||||
                toUpdate = toUpdate.Append(curSong);
 | 
					            {
 | 
				
			||||||
 | 
					                Array.Resize(ref toUpdate, toUpdate.Length + 1);
 | 
				
			||||||
 | 
					                toUpdate[toUpdate.Length - 1] = curSong;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            var ids = toUpdate.Select(s => s.SongInfo.Query.Substring(s.SongInfo.Query.LastIndexOf("?v=") + 3))
 | 
					            var ids = toUpdate.Select(s => s.SongInfo.Query.Substring(s.SongInfo.Query.LastIndexOf("?v=") + 3))
 | 
				
			||||||
                              .Distinct();
 | 
					                              .Distinct();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
 | 
					<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
 | 
				
			||||||
	<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cadministration_005Ccommands/@EntryIndexedValue">True</s:Boolean>
 | 
						<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cadministration_005Ccommands/@EntryIndexedValue">True</s:Boolean>
 | 
				
			||||||
	<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cgambling_005Ccommands/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
 | 
						<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cgambling_005Ccommands/@EntryIndexedValue">True</s:Boolean>
 | 
				
			||||||
 | 
						<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=modules_005Cgames_005Ccommands/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user