Esempio n. 1
0
        public static ShallowXanBotMember GetShallowFromDeep(XanBotMember fullMemberObject)
        {
            foreach (ShallowXanBotMember shallow in ShallowMembers)
            {
                if (shallow.DoesShallowRepresentDeep(fullMemberObject))
                {
                    return(shallow);
                }
            }
            ShallowXanBotMember member = new ShallowXanBotMember(fullMemberObject.BaseUser.Id, fullMemberObject.Context.ServerId);

            ShallowMembers.Add(member);
            return(member);
        }
Esempio n. 2
0
        /// <summary>
        /// Create a <see cref="XanBotMember"/> from a <seealso cref="DiscordUser"/> and a <seealso cref="BotContext"/>
        /// </summary>
        /// <param name="context">The context that this <see cref="XanBotMember"/> exists in.</param>
        /// <param name="user">The <seealso cref="DiscordUser"/> to create the member from.</param>
        /// <returns></returns>
        public static XanBotMember GetMemberFromUser(BotContext context, DiscordUser user)
        {
            if (user == null)
            {
                return(null);
            }
            if (XBMCache.TryGetValue(context, out Dictionary <ulong, XanBotMember> registry))
            {
                if (registry.TryGetValue(user.Id, out XanBotMember result))
                {
                    return(result);
                }
            }
            else
            {
                XBMCache[context] = new Dictionary <ulong, XanBotMember>();
            }
            XanBotMember member = new XanBotMember(context, user);

            XBMCache[context][member.Id] = member;
            return(member);
        }
Esempio n. 3
0
 public bool DoesShallowRepresentDeep(XanBotMember deep)
 {
     return(UserId == deep.BaseUser.Id && ServerId == deep.Context.ServerId);
 }