Add greetings in 299 languages

This commit is contained in:
runebaas 2020-06-18 19:19:02 +02:00
parent 8018d5e750
commit 12199f4ad4
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
3 changed files with 1660 additions and 0 deletions

View file

@ -0,0 +1,10 @@
namespace Geekbot.net.Commands.Randomness.Greetings
{
public class GreetingDto
{
public string Text { get; set; }
public string Language { get; set; }
public string Dialect { get; set; } = null;
public string Romanization { get; set; } = null;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
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)]
[Alias("greeting")]
[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)
{
eb.AddInlineField("Romanization", greeting.Romanization);
}
await ReplyAsync(string.Empty, false, eb.Build());
}
catch (Exception e)
{
await _errorHandler.HandleCommandException(e, Context);
}
}
}
}