/// <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; } }
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); }
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); }
internal static RpcUser Create(DiscordRpcClient discord, Model model) { var entity = new RpcUser(discord, model.Id); entity.Update(model); return(entity); }
internal static RpcWebhookUser Create(DiscordRpcClient discord, Model model, ulong webhookId) { var entity = new RpcWebhookUser(discord, model.Id, webhookId); entity.Update(model); return(entity); }
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; } }
internal new static RestGroupUser Create(BaseDiscordClient discord, Model model) { var entity = new RestGroupUser(discord, model.Id); entity.Update(model); return(entity); }
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); }
//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; }
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); } }
//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); }
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); }
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); }
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); }
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); } }
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; } }
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); }
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; } }
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); }
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; } }
public SocketGlobalUser(Model model) : base(model) { }
public override void Update(Model model, UpdateSource source) { lock (_lockObj) base.Update(model, source); }
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); }
internal static RestUser Create(BaseDiscordClient discord, Model model) => Create(discord, null, model, null);
internal static SocketUnknownUser Create(DiscordSocketClient discord, ClientState state, Model model) { var entity = new SocketUnknownUser(discord, model.Id); entity.Update(state, model); return(entity); }
internal static RpcUser Create(DiscordRpcClient discord, Model model) => Create(discord, model, null);
public SelfUser(DiscordRestClient discord, Model model) : base(model) { Discord = discord; }
public SocketSelfUser(DiscordSocketClient discord, Model model) : base(discord, model) { }
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); }