From fe80b8701a8baa6ad07e23395b48ae017730db0a Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Mon, 9 Apr 2018 17:58:54 +0200 Subject: Only attempts to play sounds, if in Voicechannel --- DiscoBot/Commands/Voice.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'DiscoBot/Commands/Voice.cs') diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs index 3391452..7b28965 100644 --- a/DiscoBot/Commands/Voice.cs +++ b/DiscoBot/Commands/Voice.cs @@ -19,12 +19,19 @@ public static async Task SendAsync(string path, int volume = 256) { + if (Client == null) + { + throw new NullReferenceException("Bot befindet sich nicht in einem Sprachchannel"); + } + // Create FFmpeg using the previous example - var ffmpeg = CreateStream(path, volume); + var ffmpeg = CreateStream(path, volume); var output = ffmpeg.StandardOutput.BaseStream; + var discord = Client.CreatePCMStream(AudioApplication.Music); await output.CopyToAsync(discord); await discord.FlushAsync(); + } [Command("join", RunMode = RunMode.Async)] @@ -51,6 +58,7 @@ { if (Client != null) { + await SoundEffects.Play(Sound.Nooo); await Client.StopAsync(); Client = null; } @@ -71,7 +79,7 @@ soundList.Add((Sound)sound); } - var sc = new SpellCorrect(); + var sc = new SpellCorrect(); var tSound = soundList.OrderBy(x => sc.Compare(path, x.ToString())).First(); -- cgit v1.2.3-54-g00ecf