geekbot/Geekbot.net/Modules/Dog.cs

26 lines
732 B
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using Discord.Commands;
using RestSharp;
namespace Geekbot.net.Modules
{
public class Dog : ModuleBase
{
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()
{
var dogClient = new RestClient("http://random.dog");
var request = new RestRequest("woof.json", Method.GET);
Console.WriteLine(dogClient.BaseUrl);
2017-09-15 22:56:03 +02:00
dogClient.ExecuteAsync<DogResponse>(request, async response => { await ReplyAsync(response.Data.url); });
}
}
public class DogResponse
{
public string url { get; set; }
}
2017-05-06 20:35:31 +02:00
}