From 871089bf26846dba07589f250806ec4d5f74cb28 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 5 Jan 2017 21:54:49 +0100 Subject: [PATCH] Fixed !!rm spam? --- .../Modules/Music/Classes/MusicControls.cs | 4 +-- src/NadekoBot/Modules/Music/Music.cs | 33 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs index be726c84..1e822f0a 100644 --- a/src/NadekoBot/Modules/Music/Classes/MusicControls.cs +++ b/src/NadekoBot/Modules/Music/Classes/MusicControls.cs @@ -77,7 +77,7 @@ namespace NadekoBot.Modules.Music.Classes public string PrettyVolume => $"🔉 {(int)(Volume * 100)}%"; - public event Action SongRemoved = delegate { }; + public event Action SongRemoved = delegate { }; public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume) { @@ -282,7 +282,7 @@ namespace NadekoBot.Modules.Music.Classes var song = playlist.ElementAtOrDefault(index); if (playlist.Remove(song) && !silent) { - SongRemoved(song); + SongRemoved(song, index); } }); diff --git a/src/NadekoBot/Modules/Music/Music.cs b/src/NadekoBot/Modules/Music/Music.cs index 9751c938..165ed935 100644 --- a/src/NadekoBot/Modules/Music/Music.cs +++ b/src/NadekoBot/Modules/Music/Music.cs @@ -466,22 +466,6 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel) return; - 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); } @@ -868,6 +852,23 @@ $"{("tracks".SnPl(musicPlayer.Playlist.Count))} | {(int)total.TotalHours}h {tota } catch { } }; + + + mp.SongRemoved += async (song, index) => + { + try + { + var embed = new EmbedBuilder() + .WithAuthor(eab => eab.WithName("Removed song #" + (index + 1)).WithMusicIcon()) + .WithDescription(song.PrettyName) + .WithFooter(ef => ef.WithText(song.PrettyInfo)) + .WithErrorColor(); + + await textCh.EmbedAsync(embed).ConfigureAwait(false); + + } + catch { } + }; return mp; }); Song resolvedSong;