From ba11eff0da67fc6d1c6035a21f4325baede01cf3 Mon Sep 17 00:00:00 2001 From: appelemac Date: Thu, 19 May 2016 20:50:04 +0200 Subject: [PATCH] wowie2 --- .../Modules/Searches/Commands/WowJokes.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 NadekoBot/Modules/Searches/Commands/WowJokes.cs diff --git a/NadekoBot/Modules/Searches/Commands/WowJokes.cs b/NadekoBot/Modules/Searches/Commands/WowJokes.cs new file mode 100644 index 00000000..3fb8cb59 --- /dev/null +++ b/NadekoBot/Modules/Searches/Commands/WowJokes.cs @@ -0,0 +1,32 @@ +using NadekoBot.Classes; +using System; +using System.Collections.Generic; +using System.Linq; +using Discord.Commands; +using Newtonsoft.Json; + +namespace NadekoBot.Modules.Searches.Commands +{ + class WowJokes : DiscordCommand + { + public WowJokes(DiscordModule module) : base(module) + { + } + + internal override void Init(CommandGroupBuilder cgb) + { + List Jokes = new List(); + + cgb.CreateCommand(Module.Prefix + "wowjoke") + .Description("Get one of Kwoth's penultimate WoW jokes.") + .Do(async e => + { + if (!Jokes.Any()) + { + Jokes = JsonConvert.DeserializeObject>("data/wowjokes.json"); + } + await e.Channel.SendMessage(Jokes[new Random().Next(0, Jokes.Count)].ToString()); + }); + } + } +}