From 9ac5925bf9c14d7113a28099e5a7bc8290d93449 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Tue, 22 Aug 2023 17:55:29 +0200 Subject: [PATCH] Make channel_type in ChannelCreateSchema of type enum "ChannelType" --- src/types/entities/channel.rs | 16 ++++++++++++++-- src/types/schema/channel.rs | 3 ++- tests/common/mod.rs | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 361ecb5..84530c9 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -176,10 +176,22 @@ pub struct DefaultReaction { pub emoji_name: Option, } -#[derive(Default, Clone, Copy, Debug, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)] +#[derive( + Default, + Clone, + Copy, + Debug, + Serialize_repr, + Deserialize_repr, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, +)] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] -#[repr(i32)] +#[repr(u32)] /// # Reference /// See pub enum ChannelType { diff --git a/src/types/schema/channel.rs b/src/types/schema/channel.rs index dd62f88..354459c 100644 --- a/src/types/schema/channel.rs +++ b/src/types/schema/channel.rs @@ -1,6 +1,7 @@ use bitflags::bitflags; use serde::{Deserialize, Serialize}; +use crate::types::ChannelType; use crate::types::{entities::PermissionOverwrite, Snowflake}; #[derive(Debug, Deserialize, Serialize, Default, PartialEq, PartialOrd)] @@ -8,7 +9,7 @@ use crate::types::{entities::PermissionOverwrite, Snowflake}; pub struct ChannelCreateSchema { pub name: String, #[serde(rename = "type")] - pub channel_type: Option, + pub channel_type: Option, pub topic: Option, pub icon: Option, pub bitrate: Option, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 029df2d..2dc0718 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -73,7 +73,7 @@ pub(crate) async fn setup() -> TestBundle { }; let channel_create_schema = ChannelCreateSchema { name: "testchannel".to_string(), - channel_type: Some(0), + channel_type: Some(chorus::types::ChannelType::GuildText), topic: None, icon: None, bitrate: None,