2017-11-08 01:30:50 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2017-11-11 16:20:26 +01:00
|
|
|
|
using Discord;
|
2017-11-08 01:30:50 +01:00
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using Geekbot.net.Lib;
|
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Commands
|
|
|
|
|
{
|
|
|
|
|
public class Emojify : ModuleBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IErrorHandler _errorHandler;
|
|
|
|
|
private readonly IEmojiConverter _emojiConverter;
|
|
|
|
|
|
|
|
|
|
public Emojify(IErrorHandler errorHandler, IEmojiConverter emojiConverter)
|
|
|
|
|
{
|
|
|
|
|
_errorHandler = errorHandler;
|
|
|
|
|
_emojiConverter = emojiConverter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Command("emojify", RunMode = RunMode.Async)]
|
|
|
|
|
[Remarks(CommandCategories.Helpers)]
|
|
|
|
|
[Summary("Emojify text")]
|
|
|
|
|
public async Task Dflt([Remainder, Summary("text")] string text)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
2017-11-08 19:19:43 +01:00
|
|
|
|
var emojis = _emojiConverter.textToEmoji(text);
|
|
|
|
|
if (emojis.Length > 1999)
|
|
|
|
|
{
|
|
|
|
|
await ReplyAsync("I can't take that much at once!");
|
|
|
|
|
return;
|
2017-11-11 16:20:26 +01:00
|
|
|
|
}
|
|
|
|
|
var eb = new EmbedBuilder();
|
|
|
|
|
eb.WithAuthor(new EmbedAuthorBuilder()
|
|
|
|
|
{
|
|
|
|
|
IconUrl = Context.User.GetAvatarUrl(),
|
|
|
|
|
Name = $"{Context.User.Username}#{Context.User.Discriminator}"
|
|
|
|
|
});
|
|
|
|
|
eb.WithColor(new Color(59, 136, 195));
|
|
|
|
|
eb.Description = emojis;
|
|
|
|
|
await ReplyAsync("", false, eb.Build());
|
2017-11-08 01:30:50 +01:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
_errorHandler.HandleCommandException(e, Context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|