geekbot/Geekbot.net/Commands/Emojify.cs

42 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using Discord.Commands;
using Geekbot.net.Lib;
namespace Geekbot.net.Commands
{
public class Emojify : ModuleBase
{
private readonly IEmojiConverter _emojiConverter;
2017-12-29 01:53:50 +01:00
private readonly IErrorHandler _errorHandler;
public Emojify(IErrorHandler errorHandler, IEmojiConverter emojiConverter)
{
_errorHandler = errorHandler;
_emojiConverter = emojiConverter;
}
2017-12-29 01:53:50 +01:00
[Command("emojify", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Helpers)]
[Summary("Emojify text")]
2017-12-29 01:53:50 +01:00
public async Task Dflt([Remainder] [Summary("text")] string text)
{
try
{
2018-04-30 23:44:19 +02:00
var emojis = _emojiConverter.TextToEmoji(text);
if (emojis.Length > 1999)
{
await ReplyAsync("I can't take that much at once!");
return;
}
2017-12-29 01:53:50 +01:00
await ReplyAsync($"{Context.User.Username}#{Context.User.Discriminator} said:");
await ReplyAsync(emojis);
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}