few fixes
This commit is contained in:
parent
e03b1690b1
commit
4846a15801
@ -130,7 +130,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i = 0;
|
//var i = 0;
|
||||||
if (submissions.Count == 0)
|
if (submissions.Count == 0)
|
||||||
{
|
{
|
||||||
await channel.SendErrorAsync("Acrophobia", "Game ended with no submissions.");
|
await channel.SendErrorAsync("Acrophobia", "Game ended with no submissions.");
|
||||||
|
@ -49,6 +49,8 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
|
public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
|
||||||
|
|
||||||
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
||||||
|
|
||||||
|
public string PTT => $"{PrettyTotalTime}";
|
||||||
|
|
||||||
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
||||||
|
|
||||||
@ -59,7 +61,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
if (TotalTime == TimeSpan.Zero)
|
if (TotalTime == TimeSpan.Zero)
|
||||||
return "(?)";
|
return "(?)";
|
||||||
else if (TotalTime == TimeSpan.MaxValue)
|
else if (TotalTime == TimeSpan.MaxValue)
|
||||||
return "**∞**";
|
return "∞";
|
||||||
else
|
else
|
||||||
return TotalTime.ToString(@"mm\:ss");
|
return TotalTime.ToString(@"mm\:ss");
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ 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.Text.RegularExpressions;
|
||||||
using System.Threading;
|
//using System.Threading;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Music
|
namespace NadekoBot.Modules.Music
|
||||||
{
|
{
|
||||||
@ -216,14 +216,26 @@ namespace NadekoBot.Modules.Music
|
|||||||
var currentSong = musicPlayer.CurrentSong;
|
var currentSong = musicPlayer.CurrentSong;
|
||||||
if (currentSong == null)
|
if (currentSong == null)
|
||||||
return;
|
return;
|
||||||
|
try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
var videoid = Regex.Match(currentSong.SongInfo.Query, "<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+");
|
var videoid = Regex.Match(currentSong.SongInfo.Query, "<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+");
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName("Now Playing")
|
.WithAuthor(eab => eab.WithName("Now Playing")
|
||||||
.WithMusicIcon())
|
.WithMusicIcon())
|
||||||
.WithDescription(currentSong.PrettyName)
|
.WithTitle($"{currentSong.SongInfo.Title}")
|
||||||
.WithFooter(ef => ef.WithText(currentSong.PrettyCurrentTime + "/" + currentSong.PrettyInfo))
|
.WithDescription(currentSong.PrettyCurrentTime + "/" + currentSong.PTT)
|
||||||
|
.WithFooter(ef => ef.WithText($"{currentSong.PrettyProvider} | {currentSong.QueuerName}"))
|
||||||
.WithOkColor();
|
.WithOkColor();
|
||||||
|
if (currentSong.SongInfo.Provider.Equals("YouTube", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
embed.WithThumbnail(tn => tn.Url = $"https://img.youtube.com/vi/{videoid}/0.jpg");
|
||||||
|
embed.WithUrl($"{currentSong.SongInfo.Query}");
|
||||||
|
}
|
||||||
|
else if (currentSong.SongInfo.Provider.Equals("SoundCloud", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
embed.WithThumbnail(tn => tn.Url = $"{currentSong.SongInfo.AlbumArt}");
|
||||||
|
embed.WithUrl($"{currentSong.SongInfo.Query}");
|
||||||
|
}
|
||||||
|
|
||||||
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -313,7 +325,8 @@ namespace NadekoBot.Modules.Music
|
|||||||
|
|
||||||
var msg =
|
var msg =
|
||||||
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
||||||
var cancelSource = new CancellationTokenSource();
|
|
||||||
|
/*var cancelSource = new CancellationTokenSource();
|
||||||
|
|
||||||
var tasks = Task.WhenAll(idArray.Select(async id =>
|
var tasks = Task.WhenAll(idArray.Select(async id =>
|
||||||
{
|
{
|
||||||
@ -327,7 +340,17 @@ namespace NadekoBot.Modules.Music
|
|||||||
catch { try { cancelSource.Cancel(); } catch { } }
|
catch { try { cancelSource.Cancel(); } catch { } }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await Task.WhenAny(tasks, Task.Delay(Timeout.Infinite, cancelSource.Token));
|
await Task.WhenAny(tasks, Task.Delay(Timeout.Infinite, cancelSource.Token));*/
|
||||||
|
|
||||||
|
foreach (var id in idArray)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, id, true).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (SongNotFoundException) { }
|
||||||
|
catch { break; }
|
||||||
|
}
|
||||||
|
|
||||||
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -824,6 +847,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
if (finishedMessage != null)
|
if (finishedMessage != null)
|
||||||
finishedMessage.DeleteAfter(0);
|
finishedMessage.DeleteAfter(0);
|
||||||
|
|
||||||
finishedMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
finishedMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithAuthor(eab => eab.WithName("Finished Song").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName("Finished Song").WithMusicIcon())
|
||||||
.WithDescription(song.PrettyName)
|
.WithDescription(song.PrettyName)
|
||||||
@ -839,8 +863,10 @@ namespace NadekoBot.Modules.Music
|
|||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
IUserMessage playingMessage = null;
|
IUserMessage playingMessage = null;
|
||||||
|
|
||||||
mp.OnStarted += async (player, song) =>
|
mp.OnStarted += async (player, song) =>
|
||||||
{
|
{
|
||||||
|
try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (playingMessage != null)
|
if (playingMessage != null)
|
||||||
@ -870,7 +896,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
pauseMessage = await textCh.SendConfirmAsync("🎵 Music playback **resumed**.").ConfigureAwait(false);
|
pauseMessage = await textCh.SendConfirmAsync("🎵 Music playback **resumed**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
if (pauseMessage != null)
|
if (pauseMessage != null)
|
||||||
pauseMessage.DeleteAfter(15);
|
pauseMessage.DeleteAfter(5);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user