siscodeorg / sisbase

An easy to use discord bot base for D#+. Discord Link :
https://discord.gg/ycvm6xJ
MIT License
1 stars 0 forks source link

Improve Unicode emoji support (currently Utils/Unicode.cs) #32

Open wffirilat opened 4 years ago

wffirilat commented 4 years ago

(see this comment on #31 for motivating discussion)

Current Status:

Utils/Unicode.cs contains a list of unicode code points and discord emoji names, and provides two dictionaries Emojis and UnicodeEmojisByDiscordName that contain the forward and reverse mappings.

Proposed Changes:

alikindsys commented 4 years ago

Proposed names for the class: UnicodeEmojiUtils or EmojiUtils.

About the helper functions, I completely agree. But the proposed names are too big for their own good.

Making them an extension method string#ToDiscordName string#ToUnicodeChar and add string#IsUnicodeEmoji as new helper functions could be the solution.

Usage:

var emoji = ":ok_hand:".ToUnicodeChar(); //Transforms a simple discord name onto a unicode char

if(str.Split(" ").Any(x => x.IsUnicodeEmoji())) //Checks if string has an unicode emoji

It could also be neat to migrate the custom emoji name check that exists on general to EmojiUtils.cs: https://github.com/siscodeorg/sisbase/blob/7b2fc4341c763a4a56a56644ed3003a496c4959e/Utils/General.cs#L98-L110 The proposed api would be the string#IsCustomEmoji extension method.