From e5e0c1c5c9fb6afd68ebe9dc075af23f46f11e25 Mon Sep 17 00:00:00 2001 From: TrueDoctor Date: Wed, 11 Apr 2018 14:41:01 +0200 Subject: General Cleanup and retructuring --- DiscoBot/Audio/AudioModule.cs | 89 ++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'DiscoBot/Audio/AudioModule.cs') diff --git a/DiscoBot/Audio/AudioModule.cs b/DiscoBot/Audio/AudioModule.cs index 0c3814f..9eaf1f2 100644 --- a/DiscoBot/Audio/AudioModule.cs +++ b/DiscoBot/Audio/AudioModule.cs @@ -12,61 +12,64 @@ using DiscoBot.Commands; using Discord; using Discord.Commands; -public class AudioModule : ModuleBase +namespace DiscoBot.Audio { - // Scroll down further for the AudioService. - // Like, way down - private readonly AudioService _service; - - // Remember to add an instance of the AudioService - // to your IServiceCollection when you initialize your bot - public AudioModule(AudioService service) - { - _service = service; - Dsa.Service = service; - } - - // You *MUST* mark these commands with 'RunMode.Async' - // otherwise the bot will not respond until the Task times out. - [Command("_join", RunMode = RunMode.Async)] - public async Task JoinCmd() + public class AudioModule : ModuleBase { - await _service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel); - } + // Scroll down further for the AudioService. + // Like, way down + private readonly AudioService _service; - // Remember to add preconditions to your commands, - // this is merely the minimal amount necessary. - // Adding more commands of your own is also encouraged. - [Command("_leave", RunMode = RunMode.Async)] - public async Task LeaveCmd() - { - await _service.LeaveAudio(Context.Guild); - } + // Remember to add an instance of the AudioService + // to your IServiceCollection when you initialize your bot + public AudioModule(AudioService service) + { + _service = service; + Dsa.Service = service; + } - [Command("_play", RunMode = RunMode.Async)] - public async Task PlayCmd([Remainder] string song) - { - if (Dsa.GeneralContext == null) + // You *MUST* mark these commands with 'RunMode.Async' + // otherwise the bot will not respond until the Task times out. + [Command("_join", RunMode = RunMode.Async)] + public async Task JoinCmd() { - Dsa.GeneralContext = this.Context; + await _service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel); } - var sounds = Enum.GetValues(typeof(Sound)); - var soundList = new List(); - foreach (var sound in sounds) + // Remember to add preconditions to your commands, + // this is merely the minimal amount necessary. + // Adding more commands of your own is also encouraged. + [Command("_leave", RunMode = RunMode.Async)] + public async Task LeaveCmd() { - soundList.Add((Sound)sound); + await _service.LeaveAudio(Context.Guild); } - var sc = new SpellCorrect(); + [Command("_play", RunMode = RunMode.Async)] + public async Task PlayCmd([Remainder] string song) + { + if (Dsa.GeneralContext == null) + { + Dsa.GeneralContext = this.Context; + } - var tSound = soundList.OrderBy(x => sc.Compare(song, x.ToString())).First(); + var sounds = Enum.GetValues(typeof(Sound)); + var soundList = new List(); + foreach (var sound in sounds) + { + soundList.Add((Sound)sound); + } - if (sc.Compare(song, tSound.ToString()) > SpellCorrect.ErrorThreshold) - { - await _service.SendAudioAsync(Context.Guild, Context.Channel, song); - } + var sc = new SpellCorrect(); + + var tSound = soundList.OrderBy(x => sc.Compare(song, x.ToString())).First(); - await SoundEffects.Play(tSound); + if (sc.Compare(song, tSound.ToString()) > SpellCorrect.ErrorThreshold) + { + await _service.SendAudioAsync(Context.Guild, Context.Channel, song); + } + + await SoundEffects.Play(tSound); + } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2