Пример #1
0
        public static bool TryParse(ReadOnlySpan <char> content, out Mention value)
        {
            content = content.TrimStart('<')
                      .TrimEnd('>');

            if (content.Length == 0)
            {
                value = default;
                return(false);
            }

            switch (content[0])
            {
            case '@':
            {
                Mention m = ParseUserMention(content[1..]);
Пример #2
0
        /// <summary>
        /// Parses an discord emoji from either a mention.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="emoji"></param>
        /// <returns></returns>
        public static bool TryParse(string text, out DiscordEmoji emoji)
        {
            if (Mention.TryParse(text, out Mention mention))
            {
                if (mention.Type == MentionType.EMOJI ||
                    mention.Type == MentionType.ANIMATED_EMOJI)
                {
                    emoji = new DiscordEmoji
                    {
                        Id       = mention.Id,
                        Name     = mention.Data,
                        Animated = mention.Type == MentionType.ANIMATED_EMOJI
                    };
                    return(true);
                }
            }

            emoji = null;
            return(false);
        }