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

View File

@ -14,7 +14,6 @@ using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using NadekoBot.Services.Database.Models;
using System.Text.RegularExpressions;
using System.Threading;
namespace NadekoBot.Modules.Music
@ -78,7 +77,10 @@ namespace NadekoBot.Modules.Music
}
}
catch { }
catch
{
// ignored
}
return Task.CompletedTask;
}
@ -216,7 +218,6 @@ namespace NadekoBot.Modules.Music
.Take(itemsPerPage)
.Select(v => $"`{++number}.` {v.PrettyFullName}"));
if (currentSong != null)
desc = $"`🔊` {currentSong.PrettyFullName}\n\n" + desc;
if (musicPlayer.RepeatSong)
@ -862,8 +863,7 @@ namespace NadekoBot.Modules.Music
textCh,
voiceCh,
relatedVideos[new NadekoRandom().Next(0, relatedVideos.Count)],
true,
musicType).ConfigureAwait(false);
true).ConfigureAwait(false);
}
}
catch { }
@ -871,7 +871,11 @@ namespace NadekoBot.Modules.Music
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;
if (sender == null)
return;
@ -915,7 +919,10 @@ namespace NadekoBot.Modules.Music
await mp.OutputTextChannel.EmbedAsync(embed).ConfigureAwait(false);
}
catch { }
catch
{
// ignored
}
};
return mp;
});
@ -946,10 +953,12 @@ namespace NadekoBot.Modules.Music
.WithThumbnailUrl(resolvedSong.Thumbnail)
.WithFooter(ef => ef.WithText(resolvedSong.PrettyProvider)))
.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
}
}
}