geekbot/Geekbot.net/Commands/Randomness/Dog/Dog.cs

38 lines
1 KiB
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
2020-07-15 02:52:13 +02:00
using Geekbot.net.Lib;
using Geekbot.net.Lib.ErrorHandling;
namespace Geekbot.net.Commands.Randomness.Dog
{
public class Dog : ModuleBase
{
private readonly IErrorHandler _errorHandler;
2017-12-29 01:53:50 +01:00
public Dog(IErrorHandler errorHandler)
{
_errorHandler = errorHandler;
}
2017-12-29 01:53:50 +01:00
2017-09-15 22:56:03 +02:00
[Command("dog", RunMode = RunMode.Async)]
[Summary("Return a random image of a dog.")]
public async Task Say()
{
try
2017-09-19 20:39:49 +02:00
{
2020-07-15 02:52:13 +02:00
var response = await HttpAbstractions.Get<DogResponseDto>(new Uri("http://random.dog/woof.json"));
var eb = new EmbedBuilder
2017-09-19 20:39:49 +02:00
{
2020-07-15 02:52:13 +02:00
ImageUrl = response.Url
};
await ReplyAsync("", false, eb.Build());
2017-09-19 20:39:49 +02:00
}
catch (Exception e)
{
await _errorHandler.HandleCommandException(e, Context);
}
}
}
2017-05-06 20:35:31 +02:00
}