diff options
author | Kobert <Kassian.Kobert@gmail.com> | 2018-04-09 20:44:42 +0200 |
---|---|---|
committer | Kobert <Kassian.Kobert@gmail.com> | 2018-04-09 20:44:42 +0200 |
commit | 8bfd733d009c1777463500bc515336edabdf920c (patch) | |
tree | 76c3c6d3ded78ebd37f6613e35476afc0c7aa4fc | |
parent | fcee15963e9e83fe5cae01300f26d9bcf3eb4e6c (diff) | |
parent | bdf2b48e9939c0bcc91608963b610ba26bf3e90e (diff) |
Merge branch 'master' of https://github.com/TrueDoctor/DiscoBot
-rw-r--r-- | DiscoBot/Auxiliary/Soundeffects.cs | 7 | ||||
-rw-r--r-- | DiscoBot/Commands/Voice.cs | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/DiscoBot/Auxiliary/Soundeffects.cs b/DiscoBot/Auxiliary/Soundeffects.cs index d275eb4..d04b1c0 100644 --- a/DiscoBot/Auxiliary/Soundeffects.cs +++ b/DiscoBot/Auxiliary/Soundeffects.cs @@ -21,7 +21,7 @@ namespace DiscoBot.Auxiliary public static class SoundEffects { - public static Task Play(Sound s) + public static async Task Play(Sound s) { string url = string.Empty; int vol = 256; @@ -53,10 +53,11 @@ namespace DiscoBot.Auxiliary if (url != string.Empty) { - return Voice.SendAsync(url, vol); + await Task.Run(() => Voice.SendAsync(url, vol)); + return; } - return Dsa.GeneralContext.Channel.SendMessageAsync("Ton Existiert nicht"); + await Dsa.GeneralContext.Channel.SendMessageAsync("Ton Existiert nicht"); } } } diff --git a/DiscoBot/Commands/Voice.cs b/DiscoBot/Commands/Voice.cs index 7b28965..7ffb029 100644 --- a/DiscoBot/Commands/Voice.cs +++ b/DiscoBot/Commands/Voice.cs @@ -30,6 +30,7 @@ var discord = Client.CreatePCMStream(AudioApplication.Music); await output.CopyToAsync(discord); + await discord.FlushAsync(); } @@ -65,11 +66,11 @@ } [Command("play")] - public Task PlayAudioAsync(string path) + public async Task PlayAudioAsync(string path) { if (Client == null) { - return this.Context.Channel.SendMessageAsync("Erst Joinen!"); + await this.Context.Channel.SendMessageAsync("Erst Joinen!"); } var sounds = Enum.GetValues(typeof(Sound)); @@ -85,10 +86,10 @@ if (sc.Compare(path, tSound.ToString()) > SpellCorrect.ErrorThreshold) { - return SendAsync(path); + await Task.Run(() => Voice.SendAsync(path)); } - return SoundEffects.Play(tSound); + await Task.Run(() => SoundEffects.Play(tSound)); } private static Process CreateStream(string path, int vol = 256) |