diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /DiscoBot/Audio/Voice.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DiscoBot/Audio/Voice.cs')
-rw-r--r-- | DiscoBot/Audio/Voice.cs | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/DiscoBot/Audio/Voice.cs b/DiscoBot/Audio/Voice.cs index 379f65b..c2a3097 100644 --- a/DiscoBot/Audio/Voice.cs +++ b/DiscoBot/Audio/Voice.cs @@ -1,42 +1,34 @@ -namespace DiscoBot.Audio +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Threading.Tasks; +using DiscoBot.Auxiliary; +using Discord; +using Discord.Audio; +using Discord.Commands; + +namespace DiscoBot.Audio { - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Diagnostics; - using System.Linq; - using System.Threading.Tasks; - - using DiscoBot.Auxiliary; - using DiscoBot.DSA_Game; - - using Discord; - using Discord.Audio; - using Discord.Commands; - using Discord.WebSocket; - public class Voice : ModuleBase { public static IAudioClient Client { get; set; } public static void Send(string path, int volume = 256) { - if (Client == null) - { - throw new NullReferenceException("Bot befindet sich nicht in einem Sprachchannel"); - } + 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 output = ffmpeg.StandardOutput.BaseStream; var barInvoker = new BackgroundWorker(); barInvoker.DoWork += delegate - { - var discord = Client.CreatePCMStream(AudioApplication.Music); - output.CopyToAsync(discord); + { + var discord = Client.CreatePCMStream(AudioApplication.Music); + output.CopyToAsync(discord); - discord.FlushAsync(); - }; + discord.FlushAsync(); + }; barInvoker.RunWorkerAsync(); } @@ -44,7 +36,7 @@ [Command("join", RunMode = RunMode.Async)] public async Task JoinChannelAsync(IVoiceChannel channel = null) { - var msg = this.Context.Message; + var msg = Context.Message; // Get the audio channel channel = channel ?? (msg.Author as IGuildUser)?.VoiceChannel; @@ -67,37 +59,22 @@ if (Client != null) { - SoundEffects.Play("Nooo"); await Client.StopAsync(); Client = null; } } - [Command("volume")] - public void SetVolume(int volume) - { - if (volume <= 100 && volume >= 0) - { - SoundEffects.MaxVolume = volume; - } - } [Command("play", RunMode = RunMode.Async)] public async Task PlayAudioAsync(string path) { - if (Client == null) - { - await this.Context.Channel.SendMessageAsync("Erst Joinen!"); - } + if (Client == null) await Context.Channel.SendMessageAsync("Erst Joinen!"); - SoundEffects.Play(path); + //SoundEffects.Play(path); var sounds = Enum.GetValues(typeof(Sound)); var soundList = new List<Sound>(); - foreach (var sound in sounds) - { - soundList.Add((Sound)sound); - } + foreach (var sound in sounds) soundList.Add((Sound) sound); var sc = new SpellCorrect(); } @@ -109,9 +86,9 @@ FileName = "ffmpeg", Arguments = $"-i {path} -ac 2 -f s16le -ar 48000 -ab 620000 -vol {vol} pipe:1", UseShellExecute = false, - RedirectStandardOutput = true, + RedirectStandardOutput = true }; return Process.Start(ffmpeg); } } -} +}
\ No newline at end of file |