internal static SocketSimpleUser Create(DiscordSocketClient discord, ClientState state, Model model) { var entity = new SocketSimpleUser(discord, model.Id); entity.Update(state, model); return(entity); }
internal override void Update(ClientState state, Model model) { base.Update(state, model); if (model.IsTextToSpeech.IsSpecified) { _isTTS = model.IsTextToSpeech.Value; } if (model.Pinned.IsSpecified) { _isPinned = model.Pinned.Value; } if (model.EditedTimestamp.IsSpecified) { _editedTimestampTicks = model.EditedTimestamp.Value?.UtcTicks; } if (model.MentionEveryone.IsSpecified) { _isMentioningEveryone = model.MentionEveryone.Value; } if (model.WebhookId.IsSpecified) { _webhookId = model.WebhookId.Value; } if (model.Attachments.IsSpecified) { var value = model.Attachments.Value; if (value.Length > 0) { var attachments = ImmutableArray.CreateBuilder <Attachment>(value.Length); for (int i = 0; i < value.Length; i++) { attachments.Add(Attachment.Create(value[i])); } _attachments = attachments.ToImmutable(); } else { _attachments = ImmutableArray.Create <Attachment>(); } } if (model.Embeds.IsSpecified) { var value = model.Embeds.Value; if (value.Length > 0) { var embeds = ImmutableArray.CreateBuilder <Embed>(value.Length); for (int i = 0; i < value.Length; i++) { embeds.Add(value[i].ToEntity()); } _embeds = embeds.ToImmutable(); } else { _embeds = ImmutableArray.Create <Embed>(); } } ImmutableArray <IUser> mentions = ImmutableArray.Create <IUser>(); if (model.UserMentions.IsSpecified) { var value = model.UserMentions.Value; if (value.Length > 0) { var newMentions = ImmutableArray.CreateBuilder <IUser>(value.Length); for (int i = 0; i < value.Length; i++) { var val = value[i]; if (val.Object != null) { newMentions.Add(SocketSimpleUser.Create(Discord, Discord.State, val.Object)); } } mentions = newMentions.ToImmutable(); } } if (model.Content.IsSpecified) { var text = model.Content.Value; var guild = (Channel as SocketGuildChannel)?.Guild; _tags = MessageHelper.ParseTags(text, Channel, guild, mentions); model.Content = text; } }