Exemplo n.º 1
0
        internal User AddUser(APIMember model, bool cachePerms, bool incrementCount)
        {
            if (incrementCount)
            {
                _userCount++;
            }

            Member member;

            if (!_users.TryGetValue(model.User.Id, out member)) //Users can only be added from websocket thread, ignore threadsafety
            {
                member = new Member(new User(model, Client, this), ServerPermissions.None);
                if (model.User.Id == Client.CurrentUser.Id)
                {
                    member.User.CurrentGame = Client.CurrentGame;
                    member.User.Status      = Client.Status;
                }

                _users[model.User.Id] = member;
                if (cachePerms && Client.Config.UsePermissionsCache)
                {
                    foreach (var channel in _channels)
                    {
                        channel.Value.AddUser(member.User);
                    }
                }
            }
            return(member.User);
        }
Exemplo n.º 2
0
 internal User(APIMember model, DiscordClient client, Server server)
     : this(model.User.Id, client, server)
 {
     if (server == null)
     {
         UpdateRoles(null);
     }
     Update(model);
 }
Exemplo n.º 3
0
        internal void Update(APIMember model)
        {
            if (model.User != null)
            {
                Update(model.User);
            }

            if (model.JoinedAt.HasValue)
            {
                JoinedAt = model.JoinedAt.Value;
            }
            if (model.Roles != null)
            {
                UpdateRoles(model.Roles.Select(x => Server.GetRole(x)));
            }
        }