From 1069a9cb648429682fc59cdb6dbd3e8610e188ba Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Mon, 9 Apr 2018 15:28:37 +0200 Subject: preveted Bot from trying to play Misuc before joining a channel --- DiscoBot/Commands/Voice.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'DiscoBot') diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs index 02210e8..772d807 100644 --- a/DiscoBot/Commands/Voice.cs +++ b/DiscoBot/Commands/Voice.cs @@ -30,16 +30,19 @@ } [Command("leave", RunMode = RunMode.Async)] - public Task LeaveChannelAsync(IVoiceChannel channel = null) + public async Task LeaveChannelAsync(IVoiceChannel channel = null) { - // For the next step with transmitting audio, you would want to pass this Audio Client in to a service. - return Client.StopAsync(); + if (Client != null) + { + await Client.StopAsync(); + Client = null; + } } [Command("play")] public Task PlayAudioAsync(string path) { - return SendAsync(path); + return Client == null ? this.Context.Channel.SendMessageAsync("Erst Joinen!") : SendAsync(path); } private static Process CreateStream(string path) -- cgit v1.2.3-70-g09d2