Revert "getlink takes optional param now"

This reverts commit ea99d315c4.
This commit is contained in:
appelemac 2016-07-29 15:11:54 +02:00
parent ea99d315c4
commit e2195f5f66
2 changed files with 5 additions and 24 deletions

View File

@ -756,35 +756,16 @@ namespace NadekoBot.Modules.Music
cgb.CreateCommand(Prefix + "getlink") cgb.CreateCommand(Prefix + "getlink")
.Alias(Prefix + "gl") .Alias(Prefix + "gl")
.Description("Shows a link to the song in the queue by index, or the currently playing song by default.") .Description("Shows a link to the currently playing song.")
.Parameter("index", ParameterType.Optional)
.Do(async e => .Do(async e =>
{ {
MusicPlayer musicPlayer; MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return; return;
int index; var curSong = musicPlayer.CurrentSong;
string arg = e.GetArg("index")?.Trim(); if (curSong == null)
if (!string.IsNullOrEmpty(arg) && int.TryParse(arg, out index)) return;
{ await e.Channel.SendMessage($"🎶`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false);
var selSong = musicPlayer.Playlist.DefaultIfEmpty(null).ElementAtOrDefault(index - 1);
if (selSong == null)
{
await e.Channel.SendMessage("Could not select song, likely wrong index");
} else
{
await e.Channel.SendMessage($"🎶`Selected song {selSong.SongInfo.Title}:` <{selSong.SongInfo.Query}>").ConfigureAwait(false);
}
} else
{
var curSong = musicPlayer.CurrentSong;
if (curSong == null)
return;
await e.Channel.SendMessage($"🎶`Current song:` <{curSong.SongInfo.Query}>").ConfigureAwait(false);
}
}); });
cgb.CreateCommand(Prefix + "autoplay") cgb.CreateCommand(Prefix + "autoplay")