summaryrefslogtreecommitdiff
path: root/DiscoBot/Commands/Voice.cs
diff options
context:
space:
mode:
authorTrueDoctor <d-kobert@web.de>2018-04-09 17:58:54 +0200
committerTrueDoctor <d-kobert@web.de>2018-04-09 17:58:54 +0200
commitfe80b8701a8baa6ad07e23395b48ae017730db0a (patch)
tree3724c61f0d49e0224910ad9c5bc7442011a407b6 /DiscoBot/Commands/Voice.cs
parent9b9de3a9c72f82e4d58b54e87e266d7048fe2599 (diff)
Only attempts to play sounds, if in Voicechannel
Diffstat (limited to 'DiscoBot/Commands/Voice.cs')
-rw-r--r--DiscoBot/Commands/Voice.cs12
1 files changed, 10 insertions, 2 deletions
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();