| 109 | type Error = anyhow::Error; |
| 110 | |
| 111 | fn try_from( |
| 112 | mut v: twilight_model::gateway::payload::incoming::MessageUpdate, |
| 113 | ) -> Result<Self, Self::Error> { |
| 114 | Ok(Self { |
| 115 | attachments: Some(v.attachments.drain(..).map(From::from).collect()), |
| 116 | author: Some(v.author.clone().into()), |
| 117 | channel_id: v.channel_id.to_string(), |
| 118 | content: Some(v.content.clone()), |
| 119 | edited_timestamp: v |
| 120 | .edited_timestamp |
| 121 | .map(|ts| NotBigU64(ts.as_micros() as u64 / 1000)), |
| 122 | embeds: Some(v.embeds.drain(..).map(From::from).collect()), |
| 123 | guild_id: v.guild_id.as_ref().map(ToString::to_string), |
| 124 | id: v.id.to_string(), |
| 125 | kind: Some(TryFrom::try_from(v.kind)?), |
| 126 | mention_everyone: Some(v.mention_everyone), |
| 127 | mention_roles: Some(v.mention_roles.iter().map(ToString::to_string).collect()), |
| 128 | mentions: Some(v.mentions.drain(..).map(From::from).collect()), |
| 129 | pinned: Some(v.pinned), |
| 130 | timestamp: Some(NotBigU64(v.timestamp.as_micros() as u64 / 1000)), |
| 131 | tts: Some(v.tts), |
| 132 | }) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | #[derive(Clone, Debug, Serialize, TS)] |