!!rm improved, both code and prettyness
This commit is contained in:
parent
adb1e570dd
commit
520fbe917f
@ -77,6 +77,8 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
|
||||
public string PrettyVolume => $"🔉 {(int)(Volume * 100)}%";
|
||||
|
||||
public event Action<Song> SongRemoved = delegate { };
|
||||
|
||||
public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume)
|
||||
{
|
||||
if (startingVoiceChannel == null)
|
||||
@ -277,7 +279,12 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
{
|
||||
if (index < 0 || index >= playlist.Count)
|
||||
return;
|
||||
playlist.RemoveAt(index);
|
||||
var song = playlist.ElementAtOrDefault(index);
|
||||
if (playlist.Remove(song))
|
||||
{
|
||||
SongRemoved(song);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -461,27 +461,29 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota
|
||||
public async Task Remove(int num)
|
||||
{
|
||||
|
||||
|
||||
MusicPlayer musicPlayer;
|
||||
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||
return;
|
||||
if (num <= 0 || num > musicPlayer.Playlist.Count)
|
||||
return;
|
||||
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
||||
musicPlayer.SongRemoved += async (song) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
.WithAuthor(eab => eab.WithName("Removed song #" + num).WithMusicIcon())
|
||||
.WithDescription(song.PrettyName)
|
||||
.WithFooter(ef => ef.WithText(song.PrettyInfo))
|
||||
.WithErrorColor();
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
|
||||
}
|
||||
catch { }
|
||||
};
|
||||
|
||||
musicPlayer.RemoveSongAt(num - 1);
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
.WithAuthor(eab => eab.WithName("Song Removed!").WithMusicIcon())
|
||||
.AddField(fb => fb.WithName("**Song Position**").WithValue($"#{num}").WithIsInline(true))
|
||||
.AddField(fb => fb.WithName("**Song Name**").WithValue(song.PrettyName).WithIsInline(true))
|
||||
.WithFooter(ef => ef.WithText($"{song.PrettyProvider} | {song.QueuerName}"))
|
||||
.WithErrorColor();
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
|
Loading…
Reference in New Issue
Block a user