Enable cat command again
This commit is contained in:
parent
f127e0c02b
commit
3f02f90d70
1 changed files with 57 additions and 58 deletions
|
@ -1,59 +1,58 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Geekbot.net.Lib;
|
using Geekbot.net.Lib;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Geekbot.net.Commands
|
namespace Geekbot.net.Commands
|
||||||
{
|
{
|
||||||
public class Cat : ModuleBase
|
public class Cat : ModuleBase
|
||||||
{
|
{
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
|
|
||||||
public Cat(IErrorHandler errorHandler)
|
public Cat(IErrorHandler errorHandler)
|
||||||
{
|
{
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("cat", RunMode = RunMode.Async)]
|
[Command("cat", RunMode = RunMode.Async)]
|
||||||
[Remarks(CommandCategories.Randomness)]
|
[Remarks(CommandCategories.Randomness)]
|
||||||
[Summary("Return a random image of a cat.")]
|
[Summary("Return a random image of a cat.")]
|
||||||
public async Task Say()
|
public async Task Say()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
// {
|
{
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
// client.BaseAddress = new Uri("http://random.cat");
|
client.BaseAddress = new Uri("https://aws.random.cat");
|
||||||
// var response = await client.GetAsync("/meow.php");
|
var response = await client.GetAsync("/meow");
|
||||||
// response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
//
|
|
||||||
// var stringResponse = await response.Content.ReadAsStringAsync();
|
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||||
// var catFile = JsonConvert.DeserializeObject<CatResponse>(stringResponse);
|
var catFile = JsonConvert.DeserializeObject<CatResponse>(stringResponse);
|
||||||
// var eb = new EmbedBuilder();
|
var eb = new EmbedBuilder();
|
||||||
// eb.ImageUrl = catFile.file;
|
eb.ImageUrl = catFile.file;
|
||||||
// await ReplyAsync("", false, eb.Build());
|
await ReplyAsync("", false, eb.Build());
|
||||||
// }
|
}
|
||||||
// catch (HttpRequestException e)
|
catch
|
||||||
// {
|
{
|
||||||
// await ReplyAsync($"Seems like the dog cought the cat (error occured)\r\n{e.Message}");
|
await ReplyAsync("Seems like the dog cought the cat (error occured)");
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
await ReplyAsync("Command disabled for now because http://random.cat is down");
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
_errorHandler.HandleCommandException(e, Context);
|
||||||
_errorHandler.HandleCommandException(e, Context);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private class CatResponse
|
||||||
private class CatResponse
|
{
|
||||||
{
|
public string file { get; set; }
|
||||||
public string file { get; set; }
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue