From a1de3538cd968a4b9227be4e46dac59364f40157 Mon Sep 17 00:00:00 2001 From: runebaas Date: Sun, 7 Jan 2018 23:26:20 +0100 Subject: [PATCH] Add !gdq command --- Geekbot.net/Commands/Gdq.cs | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Geekbot.net/Commands/Gdq.cs diff --git a/Geekbot.net/Commands/Gdq.cs b/Geekbot.net/Commands/Gdq.cs new file mode 100644 index 0000000..b191d6c --- /dev/null +++ b/Geekbot.net/Commands/Gdq.cs @@ -0,0 +1,41 @@ +using System; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using Geekbot.net.Lib; + +namespace Geekbot.net.Commands +{ + public class Gdq : ModuleBase + { + private readonly IErrorHandler _errorHandler; + + public Gdq(IErrorHandler errorHandler) + { + _errorHandler = errorHandler; + } + + [Command("gdq", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Games)] + [Summary("Get a quote from the GDQ donation generator.")] + public async Task getQuote() + { + try + { + using (var client = new WebClient()) + { + var url = new Uri("http://taskinoz.com/gdq/api/"); + var response = client.DownloadString(url); + + await ReplyAsync(response); + } + } + catch (Exception e) + { + _errorHandler.HandleCommandException(e, Context); + } + } + } +} \ No newline at end of file