2020-06-18 19:19:02 +02:00
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Discord;
|
|
|
|
using Discord.Commands;
|
|
|
|
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
|
|
|
|
{
|
|
|
|
var greeting = GreetingProvider.Greetings[new Random().Next(GreetingProvider.GreetingCount - 1)];
|
|
|
|
|
|
|
|
var eb = new EmbedBuilder();
|
|
|
|
eb.Title = greeting.Text;
|
|
|
|
eb.AddInlineField("Language", greeting.Language);
|
|
|
|
|
|
|
|
if (greeting.Dialect != null)
|
|
|
|
{
|
|
|
|
eb.AddInlineField("Dialect", greeting.Dialect);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (greeting.Romanization != null)
|
|
|
|
{
|
2020-06-19 00:10:43 +02:00
|
|
|
eb.AddInlineField("Roman", greeting.Romanization);
|
2020-06-18 19:19:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
await ReplyAsync(string.Empty, false, eb.Build());
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
await _errorHandler.HandleCommandException(e, Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|