Esempio n. 1
0
        /// <inheritdoc />
        internal override void Update(Model model)
        {
            base.Update(model);

            if (model.Email.IsSpecified)
            {
                Email = model.Email.Value;
            }
            if (model.Verified.IsSpecified)
            {
                IsVerified = model.Verified.Value;
            }
            if (model.MfaEnabled.IsSpecified)
            {
                IsMfaEnabled = model.MfaEnabled.Value;
            }
            if (model.Flags.IsSpecified)
            {
                Flags = (UserProperties)model.Flags.Value;
            }
            if (model.PremiumType.IsSpecified)
            {
                PremiumType = model.PremiumType.Value;
            }
            if (model.Locale.IsSpecified)
            {
                Locale = model.Locale.Value;
            }
        }
Esempio n. 2
0
        internal virtual bool Update(ClientState state, Model model)
        {
            bool hasChanges = false;

            if (model.Avatar.IsSpecified && model.Avatar.Value != AvatarId)
            {
                AvatarId   = model.Avatar.Value;
                hasChanges = true;
            }
            if (model.Discriminator.IsSpecified)
            {
                var newVal = ushort.Parse(model.Discriminator.Value, NumberStyles.None, CultureInfo.InvariantCulture);
                if (newVal != DiscriminatorValue)
                {
                    DiscriminatorValue = ushort.Parse(model.Discriminator.Value, NumberStyles.None, CultureInfo.InvariantCulture);
                    hasChanges         = true;
                }
            }
            if (model.Bot.IsSpecified && model.Bot.Value != IsBot)
            {
                IsBot      = model.Bot.Value;
                hasChanges = true;
            }
            if (model.Username.IsSpecified && model.Username.Value != Username)
            {
                Username   = model.Username.Value;
                hasChanges = true;
            }
            if (model.PublicFlags.IsSpecified && model.PublicFlags.Value != PublicFlags)
            {
                PublicFlags = model.PublicFlags.Value;
                hasChanges  = true;
            }
            return(hasChanges);
        }
Esempio n. 3
0
        internal virtual bool Update(ClientState state, Model model)
        {
            bool hasChanges = false;

            if (model.Avatar.IsSpecified && model.Avatar.Value != AvatarId)
            {
                AvatarId   = model.Avatar.Value;
                hasChanges = true;
            }
            if (model.Discriminator.IsSpecified)
            {
                var newVal = ushort.Parse(model.Discriminator.Value);
                if (newVal != DiscriminatorValue)
                {
                    DiscriminatorValue = ushort.Parse(model.Discriminator.Value);
                    hasChanges         = true;
                }
            }
            if (model.Bot.IsSpecified && model.Bot.Value != IsBot)
            {
                IsBot      = model.Bot.Value;
                hasChanges = true;
            }
            if (model.Username.IsSpecified && model.Username.Value != Username)
            {
                Username   = model.Username.Value;
                hasChanges = true;
            }
            return(hasChanges);
        }
Esempio n. 4
0
        internal static RpcUser Create(DiscordRpcClient discord, Model model)
        {
            var entity = new RpcUser(discord, model.Id);

            entity.Update(model);
            return(entity);
        }
Esempio n. 5
0
        internal static RpcWebhookUser Create(DiscordRpcClient discord, Model model, ulong webhookId)
        {
            var entity = new RpcWebhookUser(discord, model.Id, webhookId);

            entity.Update(model);
            return(entity);
        }
Esempio n. 6
0
 internal virtual void Update(Model model)
 {
     if (model.Avatar.IsSpecified)
     {
         AvatarId = model.Avatar.Value;
     }
     if (model.Banner.IsSpecified)
     {
         BannerId = model.Banner.Value;
     }
     if (model.AccentColor.IsSpecified)
     {
         AccentColor = model.AccentColor.Value;
     }
     if (model.Discriminator.IsSpecified)
     {
         DiscriminatorValue = ushort.Parse(model.Discriminator.Value, NumberStyles.None, CultureInfo.InvariantCulture);
     }
     if (model.Bot.IsSpecified)
     {
         IsBot = model.Bot.Value;
     }
     if (model.Username.IsSpecified)
     {
         Username = model.Username.Value;
     }
     if (model.PublicFlags.IsSpecified)
     {
         PublicFlags = model.PublicFlags.Value;
     }
 }
Esempio n. 7
0
        internal new static RestGroupUser Create(BaseDiscordClient discord, Model model)
        {
            var entity = new RestGroupUser(discord, model.Id);

            entity.Update(model);
            return(entity);
        }
Esempio n. 8
0
        internal static SocketGuildUser Create(SocketGuild guild, ClientState state, UserModel model)
        {
            var entity = new SocketGuildUser(guild, guild.Discord.GetOrCreateUser(state, model));

            entity.Update(state, model);
            entity.UpdateRoles(new ulong[0]);
            return(entity);
        }
Esempio n. 9
0
 //Helpers
 private static IUser GetAuthor(BaseDiscordClient client, IGuild guild, UserModel model, ulong? webhookId)
 {
     IUser author = null;
     if (guild != null)
         author = guild.GetUserAsync(model.Id, CacheMode.CacheOnly).Result;
     if (author == null)
         author = RestUser.Create(client, guild, model, webhookId);
     return author;
 }
Esempio n. 10
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);
     }
 }
Esempio n. 11
0
        //Helpers
        private static IUser GetAuthor(BaseDiscordClient client, IGuild guild, UserModel model)
        {
            IUser author = null;

            if (guild != null)
            {
                author = guild.GetUserAsync(model.Id, CacheMode.CacheOnly).Result;
            }
            if (author == null)
            {
                author = RestUser.Create(client, model);
            }
            return(author);
        }
Esempio n. 12
0
 internal SocketGuildUser AddOrUpdateUser(UserModel model)
 {
     if (_members.TryGetValue(model.Id, out SocketGuildUser member))
     {
         member.GlobalUser?.Update(Discord.State, model);
     }
     else
     {
         member = SocketGuildUser.Create(this, Discord.State, model);
         _members[member.Id] = member;
         DownloadedMemberCount++;
     }
     return(member);
 }
Esempio n. 13
0
        internal static RpcUser Create(DiscordRpcClient discord, Model model, ulong?webhookId)
        {
            RpcUser entity;

            if (webhookId.HasValue)
            {
                entity = new RpcWebhookUser(discord, model.Id, webhookId.Value);
            }
            else
            {
                entity = new RpcUser(discord, model.Id);
            }
            entity.Update(model);
            return(entity);
        }
Esempio n. 14
0
        internal static RestUser Create(BaseDiscordClient discord, IGuild guild, Model model, ulong?webhookId)
        {
            RestUser entity;

            if (webhookId.HasValue)
            {
                entity = new RestWebhookUser(discord, guild, model.Id, webhookId.Value);
            }
            else
            {
                entity = new RestUser(discord, model.Id);
            }
            entity.Update(model);
            return(entity);
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
0
        internal override void Update(ClientState state, Model model)
        {
            base.Update(state, model);

            if (model.Email.IsSpecified)
            {
                Email = model.Email.Value;
            }
            if (model.Verified.IsSpecified)
            {
                IsVerified = model.Verified.Value;
            }
            if (model.MfaEnabled.IsSpecified)
            {
                IsMfaEnabled = model.MfaEnabled.Value;
            }
        }
Esempio n. 17
0
 internal virtual void Update(Model model)
 {
     if (model.Avatar.IsSpecified)
     {
         AvatarId = model.Avatar.Value;
     }
     if (model.Discriminator.IsSpecified)
     {
         DiscriminatorValue = ushort.Parse(model.Discriminator.Value);
     }
     if (model.Bot.IsSpecified)
     {
         IsBot = model.Bot.Value;
     }
     if (model.Username.IsSpecified)
     {
         Username = model.Username.Value;
     }
 }
        internal override bool Update(ClientState state, Model model)
        {
            bool hasGlobalChanges = base.Update(state, model);

            if (model.Email.IsSpecified)
            {
                Email            = model.Email.Value;
                hasGlobalChanges = true;
            }
            if (model.Verified.IsSpecified)
            {
                IsVerified       = model.Verified.Value;
                hasGlobalChanges = true;
            }
            if (model.MfaEnabled.IsSpecified)
            {
                IsMfaEnabled     = model.MfaEnabled.Value;
                hasGlobalChanges = true;
            }
            return(hasGlobalChanges);
        }
Esempio n. 19
0
        public override void Update(Model model, UpdateSource source)
        {
            if (source == UpdateSource.Rest && IsAttached)
            {
                return;
            }

            base.Update(model, source);

            if (model.Email.IsSpecified)
            {
                Email = model.Email.Value;
            }
            if (model.Verified.IsSpecified)
            {
                IsVerified = model.Verified.Value;
            }
            if (model.MfaEnabled.IsSpecified)
            {
                IsMfaEnabled = model.MfaEnabled.Value;
            }
        }
Esempio n. 20
0
        internal override bool Update(ClientState state, Model model)
        {
            bool hasGlobalChanges = base.Update(state, model);

            if (model.Email.IsSpecified)
            {
                Email            = model.Email.Value;
                hasGlobalChanges = true;
            }
            if (model.Verified.IsSpecified)
            {
                IsVerified       = model.Verified.Value;
                hasGlobalChanges = true;
            }
            if (model.MfaEnabled.IsSpecified)
            {
                IsMfaEnabled     = model.MfaEnabled.Value;
                hasGlobalChanges = true;
            }
            if (model.Flags.IsSpecified && model.Flags.Value != Flags)
            {
                Flags            = (UserProperties)model.Flags.Value;
                hasGlobalChanges = true;
            }
            if (model.PremiumType.IsSpecified && model.PremiumType.Value != PremiumType)
            {
                PremiumType      = model.PremiumType.Value;
                hasGlobalChanges = true;
            }
            if (model.Locale.IsSpecified && model.Locale.Value != Locale)
            {
                Locale           = model.Locale.Value;
                hasGlobalChanges = true;
            }
            return(hasGlobalChanges);
        }
Esempio n. 21
0
        public virtual void Update(Model model, UpdateSource source)
        {
            if (source == UpdateSource.Rest && IsAttached)
            {
                return;
            }

            if (model.Avatar.IsSpecified)
            {
                _avatarId = model.Avatar.Value;
            }
            if (model.Discriminator.IsSpecified)
            {
                DiscriminatorValue = ushort.Parse(model.Discriminator.Value);
            }
            if (model.Bot.IsSpecified)
            {
                IsBot = model.Bot.Value;
            }
            if (model.Username.IsSpecified)
            {
                Username = model.Username.Value;
            }
        }
Esempio n. 22
0
 public SocketGlobalUser(Model model)
     : base(model)
 {
 }
Esempio n. 23
0
 public override void Update(Model model, UpdateSource source)
 {
     lock (_lockObj)
         base.Update(model, source);
 }
Esempio n. 24
0
        internal static SocketWebhookUser Create(SocketGuild guild, ClientState state, Model model, ulong webhookId)
        {
            var entity = new SocketWebhookUser(guild, model.Id, webhookId);

            entity.Update(state, model);
            return(entity);
        }
Esempio n. 25
0
 internal static RestUser Create(BaseDiscordClient discord, Model model)
 => Create(discord, null, model, null);
Esempio n. 26
0
        internal static SocketUnknownUser Create(DiscordSocketClient discord, ClientState state, Model model)
        {
            var entity = new SocketUnknownUser(discord, model.Id);

            entity.Update(state, model);
            return(entity);
        }
Esempio n. 27
0
 internal static RpcUser Create(DiscordRpcClient discord, Model model)
 => Create(discord, model, null);
Esempio n. 28
0
 public SelfUser(DiscordRestClient discord, Model model)
     : base(model)
 {
     Discord = discord;
 }
Esempio n. 29
0
 public SocketSelfUser(DiscordSocketClient discord, Model model)
     : base(discord, model)
 {
 }
Esempio n. 30
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);
        }