react command added
This commit is contained in:
parent
29de185cba
commit
8274a22f1b
8 changed files with 180 additions and 76 deletions
48
helpers/emojiextractor.cs
Normal file
48
helpers/emojiextractor.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using DSharpPlus;
|
||||
using DSharpPlus.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace T3k3rg0.Helpers
|
||||
{
|
||||
public static class EmojiExtractor
|
||||
{
|
||||
public static async Task<DiscordEmoji?> ExtractAsync(string emojInput, DiscordClient client)
|
||||
{
|
||||
try
|
||||
{
|
||||
var unicodeEmoji = DiscordEmoji.FromUnicode(emojInput);
|
||||
return unicodeEmoji;
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
var namedEmoji = DiscordEmoji.FromName(client, emojInput);
|
||||
return namedEmoji;
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
ulong emojiId;
|
||||
|
||||
// Ha teljes emojiformátumban van (pl. <:nev:123456789012345678>)
|
||||
var match = System.Text.RegularExpressions.Regex.Match(emojInput, @"<a?:\w+:(\d{17,20})>");
|
||||
if (match.Success && ulong.TryParse(match.Groups[1].Value, out emojiId))
|
||||
{
|
||||
return DiscordEmoji.FromGuildEmote(client, emojiId);
|
||||
}
|
||||
|
||||
// Ha csak simán az ID-t írta be
|
||||
if (ulong.TryParse(emojInput, out emojiId))
|
||||
{
|
||||
return DiscordEmoji.FromGuildEmote(client, emojiId);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue