Ejemplo n.º 1
0
        internal static SocketGroupUser Create(SocketGroupChannel channel, ClientState state, Model model)
        {
            var entity = new SocketGroupUser(channel, channel.Discord.GetOrCreateUser(state, model));

            entity.Update(state, model);
            return(entity);
        }
Ejemplo n.º 2
0
        private void UpdateUsers(ClientState state, UserModel[] models)
        {
            var users = new ConcurrentDictionary <ulong, SocketGroupUser>(ConcurrentHashSet.DefaultConcurrencyLevel, (int)(models.Length * 1.05));

            for (int i = 0; i < models.Length; i++)
            {
                users[models[i].Id] = SocketGroupUser.Create(this, state, models[i]);
            }
            _users = users;
        }
Ejemplo n.º 3
0
 internal SocketGroupUser GetOrAddUser(UserModel model)
 {
     if (_users.TryGetValue(model.Id, out SocketGroupUser user))
     {
         return(user as SocketGroupUser);
     }
     else
     {
         var privateUser = SocketGroupUser.Create(this, Discord.State, model);
         _users[privateUser.Id] = privateUser;
         return(privateUser);
     }
 }
Ejemplo n.º 4
0
        public SocketGroupUser AddUser(UserModel model, DataStore dataStore)
        {
            GroupUser user;

            if (_users.TryGetValue(model.Id, out user))
            {
                return(user as SocketGroupUser);
            }
            else
            {
                var globalUser  = Discord.GetOrAddUser(model, dataStore);
                var privateUser = new SocketGroupUser(this, globalUser);
                _users[privateUser.Id] = privateUser;
                return(privateUser);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Converts an existing <see cref="SocketGroupUser"/> to an abstracted <see cref="ISocketGroupUser"/> value.
 /// </summary>
 /// <param name="socketGroupUser">The existing <see cref="SocketGroupUser"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketGroupUser"/>.</exception>
 /// <returns>An <see cref="ISocketGroupUser"/> that abstracts <paramref name="socketGroupUser"/>.</returns>
 public static ISocketGroupUser Abstract(this SocketGroupUser socketGroupUser)
 => new SocketGroupUserAbstraction(socketGroupUser);
Ejemplo n.º 6
0
 /// <summary>
 /// Constructs a new <see cref="SocketGroupUserAbstraction"/> around an existing <see cref="WebSocket.SocketGroupUser"/>.
 /// </summary>
 /// <param name="socketGroupUser">The value to use for <see cref="WebSocket.SocketGroupUser"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="socketGroupUser"/>.</exception>
 public SocketGroupUserAbstraction(SocketGroupUser socketGroupUser)
     : base(socketGroupUser)
 {
 }