Refaction all files into component based folders

This commit is contained in:
runebaas 2018-05-03 00:56:06 +02:00
parent 55e152f4aa
commit e3adf55742
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
102 changed files with 816 additions and 709 deletions

View file

@ -0,0 +1,54 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling;
using Newtonsoft.Json;
namespace Geekbot.net.Commands.Randomness.Dog
{
public class Dog : ModuleBase
{
private readonly IErrorHandler _errorHandler;
public Dog(IErrorHandler errorHandler)
{
_errorHandler = errorHandler;
}
[Command("dog", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Randomness)]
[Summary("Return a random image of a dog.")]
public async Task Say()
{
try
{
using (var client = new HttpClient())
{
try
{
client.BaseAddress = new Uri("http://random.dog");
var response = await client.GetAsync("/woof.json");
response.EnsureSuccessStatusCode();
var stringResponse = await response.Content.ReadAsStringAsync();
var dogFile = JsonConvert.DeserializeObject<DogResponseDto>(stringResponse);
var eb = new EmbedBuilder();
eb.ImageUrl = dogFile.Url;
await ReplyAsync("", false, eb.Build());
}
catch (HttpRequestException e)
{
await ReplyAsync($"Seems like the dog got lost (error occured)\r\n{e.Message}");
}
}
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}

View file

@ -0,0 +1,7 @@
namespace Geekbot.net.Commands.Randomness.Dog
{
internal class DogResponseDto
{
public string Url { get; set; }
}
}