People who are not in a voice channel now have much less control, Thanks to Lepia for suggestion.

This commit is contained in:
Master Kwoth 2016-04-26 10:54:44 +02:00
parent 6dce6de9e6
commit 8a58c63bf1

View File

@ -57,11 +57,12 @@ namespace NadekoBot.Modules.Music
cgb.CreateCommand("n")
.Alias("next")
.Alias("skip")
.Description("Goes to the next song in the queue.**Usage**: `!m n`")
.Description("Goes to the next song in the queue. You have to be in the same voice channel as the bot.\n**Usage**: `!m n`")
.Do(e =>
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (musicPlayer.PlaybackVoiceChannel == e.User.VoiceChannel)
musicPlayer.Next();
});
@ -74,6 +75,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
musicPlayer.Stop();
}).ConfigureAwait(false);
});
@ -88,6 +90,7 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryRemove(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel == musicPlayer.PlaybackVoiceChannel)
musicPlayer.Destroy();
}).ConfigureAwait(false);
});
@ -99,6 +102,8 @@ namespace NadekoBot.Modules.Music
{
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer)) return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.TogglePause();
if (musicPlayer.Paused)
await e.Channel.SendMessage("🎵`Music Player paused.`").ConfigureAwait(false);
@ -172,6 +177,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
var arg = e.GetArg("val");
int volume;
if (!int.TryParse(arg, out volume))
@ -208,6 +215,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(0);
});
@ -218,6 +227,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(100);
});
@ -228,6 +239,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
musicPlayer.SetVolume(50);
});
@ -238,6 +251,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
if (musicPlayer.Playlist.Count < 2)
{
await e.Channel.SendMessage("💢 Not enough songs in order to perform the shuffle.").ConfigureAwait(false);
@ -352,6 +367,8 @@ namespace NadekoBot.Modules.Music
{
return;
}
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
if (arg?.ToLower() == "all")
{
musicPlayer.ClearQueue();
@ -545,7 +562,8 @@ namespace NadekoBot.Modules.Music
MusicPlayer musicPlayer;
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
return;
if (e.User.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
return;
int skipTo;
if (!int.TryParse(skipToStr, out skipTo) || skipTo < 0)
return;