Make id(&self) return Option<Snowflake>
This commit is contained in:
parent
1144b77fbb
commit
86b1149565
|
@ -1,11 +1,13 @@
|
|||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::gateway::Updateable;
|
||||
use chorus_macros::Updateable;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||
|
||||
use crate::types::utils::Snowflake;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Default, Clone, Updateable)]
|
||||
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object>
|
||||
pub struct AutoModerationRule {
|
||||
pub id: Snowflake,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use crate::types::JsonField;
|
||||
use chorus_macros::JsonField;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{
|
||||
|
@ -5,6 +7,8 @@ use crate::types::{
|
|||
WebSocketEvent,
|
||||
};
|
||||
|
||||
use super::UpdateMessage;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
|
||||
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-create>
|
||||
pub struct AutoModerationRuleCreate {
|
||||
|
@ -14,11 +18,19 @@ pub struct AutoModerationRuleCreate {
|
|||
|
||||
impl WebSocketEvent for AutoModerationRuleCreate {}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone, JsonField)]
|
||||
/// See <https://discord.com/developers/docs/topics/gateway-events#auto-moderation-rule-update>
|
||||
pub struct AutoModerationRuleUpdate {
|
||||
#[serde(flatten)]
|
||||
pub rule: AutoModerationRule,
|
||||
#[serde(skip)]
|
||||
pub json: String,
|
||||
}
|
||||
|
||||
impl UpdateMessage<AutoModerationRule> for AutoModerationRuleUpdate {
|
||||
fn id(&self) -> Option<Snowflake> {
|
||||
Some(self.rule.id)
|
||||
}
|
||||
}
|
||||
|
||||
impl WebSocketEvent for AutoModerationRuleUpdate {}
|
||||
|
|
|
@ -43,8 +43,8 @@ impl UpdateMessage<Channel> for ChannelUpdate {
|
|||
let mut write = object_to_update.write().unwrap();
|
||||
*write = self.channel.clone();
|
||||
}
|
||||
fn id(&self) -> Snowflake {
|
||||
self.channel.id
|
||||
fn id(&self) -> Option<Snowflake> {
|
||||
Some(self.channel.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,8 +180,8 @@ pub struct GuildRoleCreate {
|
|||
impl WebSocketEvent for GuildRoleCreate {}
|
||||
|
||||
impl UpdateMessage<Guild> for GuildRoleCreate {
|
||||
fn id(&self) -> Snowflake {
|
||||
self.guild_id
|
||||
fn id(&self) -> Option<Snowflake> {
|
||||
Some(self.guild_id)
|
||||
}
|
||||
|
||||
fn update(&mut self, object_to_update: Arc<RwLock<Guild>>) {
|
||||
|
@ -210,8 +210,8 @@ pub struct GuildRoleUpdate {
|
|||
impl WebSocketEvent for GuildRoleUpdate {}
|
||||
|
||||
impl UpdateMessage<RoleObject> for GuildRoleUpdate {
|
||||
fn id(&self) -> Snowflake {
|
||||
self.role.id
|
||||
fn id(&self) -> Option<Snowflake> {
|
||||
Some(self.role.id)
|
||||
}
|
||||
|
||||
fn update(&mut self, object_to_update: Arc<RwLock<RoleObject>>) {
|
||||
|
|
|
@ -122,7 +122,7 @@ where
|
|||
fn update(&mut self, object_to_update: Arc<RwLock<T>>) {
|
||||
update_object(self.get_json(), object_to_update)
|
||||
}
|
||||
fn id(&self) -> Snowflake;
|
||||
fn id(&self) -> Option<Snowflake>;
|
||||
}
|
||||
|
||||
pub(crate) trait JsonField: Clone {
|
||||
|
|
Loading…
Reference in New Issue