internal static RpcMessage Create(DiscordRpcClient discord, ulong channelId, Model model) { //model.ChannelId is always 0, needs to be passed from the event if (model.Type == MessageType.Default) { return(RpcUserMessage.Create(discord, channelId, model)); } else { return(RpcSystemMessage.Create(discord, channelId, model)); } }
internal virtual void Update(Model model) { if (model.Timestamp.IsSpecified) { _timestampTicks = model.Timestamp.Value.UtcTicks; } if (model.Content.IsSpecified) { Content = model.Content.Value; } if (model.AuthorColor.IsSpecified) { AuthorColor = new Color(Convert.ToUInt32(model.AuthorColor.Value.Substring(1), 16)); } }
internal override void Update(Model model) { base.Update(model); Type = model.Type; }
internal new static RpcSystemMessage Create(DiscordRpcClient discord, ulong channelId, Model model) { var entity = new RpcSystemMessage(discord, model.Id, RestVirtualMessageChannel.Create(discord, channelId), RpcUser.Create(discord, model.Author.Value, model.WebhookId.ToNullable())); entity.Update(model); return(entity); }
internal override void Update(Model model) { base.Update(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.IsBlocked.IsSpecified) { _isBlocked = model.IsBlocked.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>(); } } if (model.Content.IsSpecified) { var text = model.Content.Value; _tags = MessageHelper.ParseTags(text, null, null, ImmutableArray.Create <IUser>()); model.Content = text; } }