2020-06-18 19:19:02 +02:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Discord;
|
|
|
|
using Discord.Commands;
|
2020-07-15 02:52:13 +02:00
|
|
|
using Geekbot.net.Lib;
|
2020-06-18 19:19:02 +02:00
|
|
|
using Geekbot.net.Lib.ErrorHandling;
|
|
|
|
using Geekbot.net.Lib.Extensions;
|
|
|
|
|
|
|
|
namespace Geekbot.net.Commands.Randomness.Greetings
|
|
|
|
{
|
|
|
|
public class Greetings : ModuleBase
|
|
|
|
{
|
|
|
|
private readonly IErrorHandler _errorHandler;
|
|
|
|
|
|
|
|
public Greetings(IErrorHandler errorHandler)
|
|
|
|
{
|
|
|
|
_errorHandler = errorHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Command("hello", RunMode = RunMode.Async)]
|
2020-06-19 00:10:43 +02:00
|
|
|
[Alias("greeting", "hi", "hallo")]
|
2020-06-18 19:19:02 +02:00
|
|
|
[Summary("Say hello to the bot and get a reply in a random language")]
|
|
|
|
public async Task GetGreeting()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-15 02:52:13 +02:00
|
|
|
var greeting = await HttpAbstractions.Get<GreetingBaseDto>(new Uri("https://api.greetings.dev/v1/greeting"));
|
2020-06-18 19:19:02 +02:00
|
|
|
|
|
|
|
var eb = new EmbedBuilder();
|
2020-06-30 17:54:01 +02:00
|
|
|
eb.Title = greeting.Primary.Text;
|
2020-06-18 19:19:02 +02:00
|
|
|
eb.AddInlineField("Language", greeting.Language);
|
|
|
|
|
2020-06-30 17:54:01 +02:00
|
|
|
if (greeting.Primary.Dialect != null)
|
2020-06-18 19:19:02 +02:00
|
|
|
{
|
2020-06-30 17:54:01 +02:00
|
|
|
eb.AddInlineField("Dialect", greeting.Primary.Dialect);
|
2020-06-18 19:19:02 +02:00
|
|
|
}
|
|
|
|
|
2020-06-30 17:54:01 +02:00
|
|
|
if (greeting.Primary.Romanization != null)
|
2020-06-18 19:19:02 +02:00
|
|
|
{
|
2020-06-30 17:54:01 +02:00
|
|
|
eb.AddInlineField("Roman", greeting.Primary.Romanization);
|
2020-06-18 19:19:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
await ReplyAsync(string.Empty, false, eb.Build());
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
await _errorHandler.HandleCommandException(e, Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|