Implement UpdateMessage for GuildCreate

This commit is contained in:
bitfl0wer 2023-09-05 14:41:02 +02:00
parent b3bbff5c36
commit f5569973f7
No known key found for this signature in database
GPG Key ID: 0ACD574FCF5226CF
1 changed files with 16 additions and 1 deletions

View File

@ -16,13 +16,28 @@ use super::UpdateMessage;
#[cfg(feature = "client")] #[cfg(feature = "client")]
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
#[derive(Debug, Deserialize, Serialize, Default, Clone)] #[derive(Debug, Deserialize, Serialize, Default, Clone, SourceUrlField, JsonField)]
/// See <https://discord.com/developers/docs/topics/gateway-events#guild-create>; /// See <https://discord.com/developers/docs/topics/gateway-events#guild-create>;
/// Received to give data about a guild; /// Received to give data about a guild;
// This one is particularly painful, it can be a Guild object with an extra field or an unavailable guild object // This one is particularly painful, it can be a Guild object with an extra field or an unavailable guild object
pub struct GuildCreate { pub struct GuildCreate {
#[serde(flatten)] #[serde(flatten)]
pub d: GuildCreateDataOption, pub d: GuildCreateDataOption,
#[serde(skip)]
pub source_url: String,
#[serde(skip)]
pub json: String,
}
impl UpdateMessage<Guild> for GuildCreate {
fn id(&self) -> Option<Snowflake> {
match &self.d {
GuildCreateDataOption::UnavailableGuild(unavailable) => Some(unavailable.id),
GuildCreateDataOption::Guild(guild) => Some(guild.id),
}
}
fn update(&mut self, _: Arc<RwLock<Guild>>) {}
} }
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]