!!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 string PrettyVolume => $"🔉 {(int)(Volume * 100)}%";
|
||||||
|
|
||||||
|
public event Action<Song> SongRemoved = delegate { };
|
||||||
|
|
||||||
public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume)
|
public MusicPlayer(IVoiceChannel startingVoiceChannel, float? defaultVolume)
|
||||||
{
|
{
|
||||||
if (startingVoiceChannel == null)
|
if (startingVoiceChannel == null)
|
||||||
@ -277,7 +279,12 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
{
|
{
|
||||||
if (index < 0 || index >= playlist.Count)
|
if (index < 0 || index >= playlist.Count)
|
||||||
return;
|
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)
|
public async Task Remove(int num)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(Context.Guild.Id, out musicPlayer))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
if (((IGuildUser)Context.User).VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||||
return;
|
return;
|
||||||
if (num <= 0 || num > musicPlayer.Playlist.Count)
|
musicPlayer.SongRemoved += async (song) =>
|
||||||
return;
|
{
|
||||||
var song = (musicPlayer.Playlist as List<Song>)?[num - 1];
|
try
|
||||||
musicPlayer.RemoveSongAt(num - 1);
|
{
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName("Song Removed!").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName("Removed song #" + num).WithMusicIcon())
|
||||||
.AddField(fb => fb.WithName("**Song Position**").WithValue($"#{num}").WithIsInline(true))
|
.WithDescription(song.PrettyName)
|
||||||
.AddField(fb => fb.WithName("**Song Name**").WithValue(song.PrettyName).WithIsInline(true))
|
.WithFooter(ef => ef.WithText(song.PrettyInfo))
|
||||||
.WithFooter(ef => ef.WithText($"{song.PrettyProvider} | {song.QueuerName}"))
|
|
||||||
.WithErrorColor();
|
.WithErrorColor();
|
||||||
|
|
||||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
};
|
||||||
|
|
||||||
|
musicPlayer.RemoveSongAt(num - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
Loading…
Reference in New Issue
Block a user