!!ap bug fixed

This commit is contained in:
Kwoth 2017-02-17 13:11:24 +01:00
parent cf686a20c3
commit b588da43e5
2 changed files with 29 additions and 17 deletions

View File

@ -6,12 +6,14 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog;
using VideoLibrary; using VideoLibrary;
namespace NadekoBot.Modules.Music.Classes namespace NadekoBot.Modules.Music.Classes
{ {
public static class SongHandler public static class SongHandler
{ {
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
public static async Task<Song> ResolveSong(string query, MusicType musicType = MusicType.Normal) public static async Task<Song> ResolveSong(string query, MusicType musicType = MusicType.Normal)
{ {
if (string.IsNullOrWhiteSpace(query)) if (string.IsNullOrWhiteSpace(query))
@ -106,7 +108,8 @@ namespace NadekoBot.Modules.Music.Classes
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine($"Failed resolving the link.{ex.Message}"); _log.Warn($"Failed resolving the link.{ex.Message}");
_log.Warn(ex);
return null; return null;
} }
} }
@ -137,7 +140,7 @@ namespace NadekoBot.Modules.Music.Classes
} }
catch catch
{ {
Console.WriteLine($"Failed reading .pls:\n{file}"); _log.Warn($"Failed reading .pls:\n{file}");
return null; return null;
} }
} }
@ -156,7 +159,7 @@ namespace NadekoBot.Modules.Music.Classes
} }
catch catch
{ {
Console.WriteLine($"Failed reading .m3u:\n{file}"); _log.Warn($"Failed reading .m3u:\n{file}");
return null; return null;
} }
@ -172,7 +175,7 @@ namespace NadekoBot.Modules.Music.Classes
} }
catch catch
{ {
Console.WriteLine($"Failed reading .asx:\n{file}"); _log.Warn($"Failed reading .asx:\n{file}");
return null; return null;
} }
} }
@ -192,7 +195,7 @@ namespace NadekoBot.Modules.Music.Classes
} }
catch catch
{ {
Console.WriteLine($"Failed reading .xspf:\n{file}"); _log.Warn($"Failed reading .xspf:\n{file}");
return null; return null;
} }
} }

View File

@ -14,7 +14,6 @@ using System.Net.Http;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
namespace NadekoBot.Modules.Music namespace NadekoBot.Modules.Music
@ -78,7 +77,10 @@ namespace NadekoBot.Modules.Music
} }
} }
catch { } catch
{
// ignored
}
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -216,8 +218,7 @@ namespace NadekoBot.Modules.Music
.Take(itemsPerPage) .Take(itemsPerPage)
.Select(v => $"`{++number}.` {v.PrettyFullName}")); .Select(v => $"`{++number}.` {v.PrettyFullName}"));
if (currentSong != null) desc = $"`🔊` {currentSong.PrettyFullName}\n\n" + desc;
desc = $"`🔊` {currentSong.PrettyFullName}\n\n" + desc;
if (musicPlayer.RepeatSong) if (musicPlayer.RepeatSong)
desc = "🔂 Repeating Current Song\n\n" + desc; desc = "🔂 Repeating Current Song\n\n" + desc;
@ -862,8 +863,7 @@ namespace NadekoBot.Modules.Music
textCh, textCh,
voiceCh, voiceCh,
relatedVideos[new NadekoRandom().Next(0, relatedVideos.Count)], relatedVideos[new NadekoRandom().Next(0, relatedVideos.Count)],
true, true).ConfigureAwait(false);
musicType).ConfigureAwait(false);
} }
} }
catch { } catch { }
@ -871,7 +871,11 @@ namespace NadekoBot.Modules.Music
mp.OnStarted += async (player, song) => mp.OnStarted += async (player, song) =>
{ {
try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { } try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); }
catch
{
// ignored
}
var sender = player as MusicPlayer; var sender = player as MusicPlayer;
if (sender == null) if (sender == null)
return; return;
@ -915,7 +919,10 @@ namespace NadekoBot.Modules.Music
await mp.OutputTextChannel.EmbedAsync(embed).ConfigureAwait(false); await mp.OutputTextChannel.EmbedAsync(embed).ConfigureAwait(false);
} }
catch { } catch
{
// ignored
}
}; };
return mp; return mp;
}); });
@ -946,10 +953,12 @@ namespace NadekoBot.Modules.Music
.WithThumbnailUrl(resolvedSong.Thumbnail) .WithThumbnailUrl(resolvedSong.Thumbnail)
.WithFooter(ef => ef.WithText(resolvedSong.PrettyProvider))) .WithFooter(ef => ef.WithText(resolvedSong.PrettyProvider)))
.ConfigureAwait(false); .ConfigureAwait(false);
if (queuedMessage != null) queuedMessage?.DeleteAfter(10);
queuedMessage.DeleteAfter(10);
} }
catch { } // if queued message sending fails, don't attempt to delete it catch
{
// ignored
} // if queued message sending fails, don't attempt to delete it
} }
} }
} }