Exemplo n.º 1
0
        /// <summary>
        /// Gets emoji's name in non-Unicode format (eg. :thinking: instead of the Unicode representation of the emoji).
        /// </summary>
        public string GetDiscordName()
        {
            DiscordNameLookup.TryGetValue(this.Name, out var name);

            if (name == null)
            {
                return($":{ this.Name }:");
            }

            return(name);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Attempts to create an emoji object from a unicode entity.
        /// </summary>
        /// <param name="client"><see cref="BaseDiscordClient"/> to attach to the object.</param>
        /// <param name="unicodeEntity">Unicode entity to create the object from.</param>
        /// <param name="emoji">Resulting <see cref="DiscordEmoji"/> object.</param>
        /// <returns>Whether the operation was successful.</returns>
        public static bool TryFromUnicode(BaseDiscordClient client, string unicodeEntity, out DiscordEmoji emoji)
        {
            // this is a round-trip operation because of FE0F inconsistencies.
            // through this, the inconsistency is normalized.

            emoji = null;
            if (!DiscordNameLookup.TryGetValue(unicodeEntity, out var discordName))
            {
                return(false);
            }

            if (!UnicodeEmojis.TryGetValue(discordName, out unicodeEntity))
            {
                return(false);
            }

            emoji = new DiscordEmoji {
                Name = unicodeEntity, Discord = client
            };
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets emoji's name in non-Unicode format (eg. :thinking: instead of the Unicode representation of the emoji).
        /// </summary>
        public string GetDiscordName()
        {
            DiscordNameLookup.TryGetValue(this.Name, out var name);

            return(name == null ? $":{ this.Name }:" : name);
        }