From 551c29103ba38d910da2246e44e45aef32be9e0a Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 18:27:23 +0800 Subject: [PATCH 01/12] rename GUILD_EMOJIS intent to GUILD_EMOJIS_AND_STICKERS and make corresponding changes to various types --- model/src/gateway/event/kind.rs | 2 ++ model/src/gateway/event/mod.rs | 3 +++ model/src/gateway/intents.rs | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/model/src/gateway/event/kind.rs b/model/src/gateway/event/kind.rs index 0ae8a553554..5821508e322 100644 --- a/model/src/gateway/event/kind.rs +++ b/model/src/gateway/event/kind.rs @@ -22,6 +22,7 @@ pub enum EventType { GuildDelete, GuildEmojisUpdate, GuildIntegrationsUpdate, + GuildStickersUpdate, GuildUpdate, IntegrationCreate, IntegrationDelete, @@ -97,6 +98,7 @@ impl EventType { Self::GuildDelete => Some("GUILD_DELETE"), Self::GuildEmojisUpdate => Some("GUILD_EMOJIS_UPDATE"), Self::GuildIntegrationsUpdate => Some("GUILD_INTEGRATIONS_UPDATE"), + Self::GuildStickersUpdate => Some("GUILD_STICKERS_UPDATE"), Self::GuildUpdate => Some("GUILD_UPDATE"), Self::IntegrationCreate => Some("INTEGRATION_CREATE"), Self::IntegrationDelete => Some("INTEGRATION_DELETE"), diff --git a/model/src/gateway/event/mod.rs b/model/src/gateway/event/mod.rs index 1cde5c7ba85..e2ff84888be 100644 --- a/model/src/gateway/event/mod.rs +++ b/model/src/gateway/event/mod.rs @@ -57,6 +57,8 @@ pub enum Event { GuildEmojisUpdate(GuildEmojisUpdate), /// A guild's integrations were updated. GuildIntegrationsUpdate(GuildIntegrationsUpdate), + /// A guild's stickers were updated. + GuildStickersUpdate(GuildStickersUpdate), /// A guild was updated. GuildUpdate(Box), /// A guild integration was created. @@ -181,6 +183,7 @@ impl Event { Self::GuildDelete(_) => EventType::GuildDelete, Self::GuildEmojisUpdate(_) => EventType::GuildEmojisUpdate, Self::GuildIntegrationsUpdate(_) => EventType::GuildIntegrationsUpdate, + Self::GuildStickersUpdate(_) => EventType::GuildStickersUpdate, Self::GuildUpdate(_) => EventType::GuildUpdate, Self::IntegrationCreate(_) => EventType::IntegrationCreate, Self::IntegrationDelete(_) => EventType::IntegrationDelete, diff --git a/model/src/gateway/intents.rs b/model/src/gateway/intents.rs index 9866b76a1c2..085d0131e95 100644 --- a/model/src/gateway/intents.rs +++ b/model/src/gateway/intents.rs @@ -62,13 +62,15 @@ bitflags! { /// [`GUILD_BAN_ADD`]: super::event::Event::BanAdd /// [`GUILD_BAN_REMOVE`]: super::event::Event::BanRemove const GUILD_BANS = 1 << 2; - /// Guild emojis intent. + /// Guild emojis and stickers intent. /// /// Event(s) received: /// - [`GUILD_EMOJIS_UPDATE`] + /// - [`GUILD_STICKERS_UPDATE`] /// /// [`GUILD_EMOJIS_UPDATE`]: super::event::Event::GuildEmojisUpdate - const GUILD_EMOJIS = 1 << 3; + /// [`GUILD_STICKERS_UPDATE`]: super::event::Event::GuildStickersUpdate + const GUILD_EMOJIS_AND_STICKERS = 1 << 3; /// Guild integrations intent. /// /// Event(s) received: From 020c22b10dcfe909c7578ebbf73279f25cb66bbe Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 18:38:34 +0800 Subject: [PATCH 02/12] update for standby crate --- standby/src/event.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/standby/src/event.rs b/standby/src/event.rs index 5c647cfaa31..cd78b02a236 100644 --- a/standby/src/event.rs +++ b/standby/src/event.rs @@ -31,6 +31,7 @@ pub const fn guild_id(event: &Event) -> Option> { Event::GuildDelete(e) => Some(e.id), Event::GuildEmojisUpdate(e) => Some(e.guild_id), Event::GuildIntegrationsUpdate(e) => Some(e.guild_id), + Event::GuildStickersUpdate(e) => Some(e.guild_id), Event::GuildUpdate(e) => Some(e.0.id), Event::IntegrationCreate(e) => e.0.guild_id, Event::IntegrationDelete(e) => Some(e.guild_id), From 15f82740aaa06f3107b074e3d2ee50008e64fe25 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 18:49:54 +0800 Subject: [PATCH 03/12] make corresponding changes for cache as well --- cache/in-memory/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 226b55ecb92..0a4f5bd25c7 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -940,6 +940,7 @@ impl UpdateCache for Event { GuildCreate(v) => c.update(v.deref()), GuildDelete(v) => c.update(v.deref()), GuildEmojisUpdate(v) => c.update(v), + GuildStickersUpdate(v) => c.update(v), GuildIntegrationsUpdate(_) => {} GuildUpdate(v) => c.update(v.deref()), IntegrationCreate(v) => c.update(v.deref()), From 80c7c65c0df4370763be947969fb259f666c8a2f Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:19:09 +0800 Subject: [PATCH 04/12] make changes to gateway --- gateway/src/event.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gateway/src/event.rs b/gateway/src/event.rs index 504774ce061..22f7fb10920 100644 --- a/gateway/src/event.rs +++ b/gateway/src/event.rs @@ -39,6 +39,8 @@ bitflags! { const GUILD_EMOJIS_UPDATE = 1 << 12; /// A guild's integrations have been updated. const GUILD_INTEGRATIONS_UPDATE = 1 << 13; + /// A guild's stickers have been updated. + const GUILD_STICKERS_UPDATE = 1 << 63; /// A guild has been updated. const GUILD_UPDATE = 1 << 14; /// A guild integration was created. @@ -195,11 +197,14 @@ impl EventTypeFlags { EventTypeFlags::BAN_ADD.bits() | EventTypeFlags::BAN_REMOVE.bits(), ); - /// All [`EventTypeFlags`] in [`Intents::GUILD_EMOJIS`]. + /// All [`EventTypeFlags`] in [`Intents::GUILD_EMOJIS_AND_STICKERS`]. /// - /// [`Intents::GUILD_EMOJIS`]: crate::Intents::GUILD_EMOJIS - pub const GUILD_EMOJIS: EventTypeFlags = - EventTypeFlags::from_bits_truncate(EventTypeFlags::GUILD_EMOJIS_UPDATE.bits()); + /// [`Intents::GUILD_EMOJIS_AND_STICKERS`]: crate::Intents::GUILD_EMOJIS_AND_STICKERS + pub const GUILD_EMOJIS_AND_STICKERS: EventTypeFlags = + EventTypeFlags::from_bits_truncate( + EventTypeFlags::GUILD_EMOJIS_UPDATE.bits() + | EventTypeFlags::GUILD_STICKERS_UPDATE.bits(), + ); /// All [`EventTypeFlags`] in [`Intents::GUILD_INTEGRATIONS`]. /// @@ -287,6 +292,7 @@ impl From for EventTypeFlags { EventType::GuildDelete => EventTypeFlags::GUILD_DELETE, EventType::GuildEmojisUpdate => EventTypeFlags::GUILD_EMOJIS_UPDATE, EventType::GuildIntegrationsUpdate => EventTypeFlags::GUILD_INTEGRATIONS_UPDATE, + EventType::GuildStickersUpdate => EventTypeFlags::GUILD_STICKERS_UPDATE, EventType::GuildUpdate => EventTypeFlags::GUILD_UPDATE, EventType::IntegrationCreate => EventTypeFlags::INTEGRATION_CREATE, EventType::IntegrationDelete => EventTypeFlags::INTEGRATION_DELETE, From b5553f4b75945b38e1d9c6c1570ef985bc5a8f72 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:52:12 +0800 Subject: [PATCH 05/12] update example for gateway-metrics --- examples/gateway-metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gateway-metrics.rs b/examples/gateway-metrics.rs index 1e698b6e529..7b8c7a98d0a 100644 --- a/examples/gateway-metrics.rs +++ b/examples/gateway-metrics.rs @@ -20,7 +20,7 @@ async fn main() -> Result<(), Box> { // Initialize the tracing subscriber. tracing_subscriber::fmt::init(); - let intents = Intents::GUILD_BANS | Intents::GUILD_EMOJIS | Intents::GUILD_MESSAGES; + let intents = Intents::GUILD_BANS | Intents::GUILD_EMOJIS_AND_STICKERS | Intents::GUILD_MESSAGES; let (cluster, mut events) = Cluster::new(env::var("DISCORD_TOKEN")?, intents).await?; println!("Created cluster"); From 59cca0be13c07d2755be744363be2e6b0e3478f5 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 19:56:00 +0800 Subject: [PATCH 06/12] rustfmt --- examples/gateway-metrics.rs | 3 ++- gateway/src/event.rs | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/gateway-metrics.rs b/examples/gateway-metrics.rs index 7b8c7a98d0a..52a25d5b8d2 100644 --- a/examples/gateway-metrics.rs +++ b/examples/gateway-metrics.rs @@ -20,7 +20,8 @@ async fn main() -> Result<(), Box> { // Initialize the tracing subscriber. tracing_subscriber::fmt::init(); - let intents = Intents::GUILD_BANS | Intents::GUILD_EMOJIS_AND_STICKERS | Intents::GUILD_MESSAGES; + let intents = + Intents::GUILD_BANS | Intents::GUILD_EMOJIS_AND_STICKERS | Intents::GUILD_MESSAGES; let (cluster, mut events) = Cluster::new(env::var("DISCORD_TOKEN")?, intents).await?; println!("Created cluster"); diff --git a/gateway/src/event.rs b/gateway/src/event.rs index 22f7fb10920..cae0a1164e6 100644 --- a/gateway/src/event.rs +++ b/gateway/src/event.rs @@ -200,11 +200,9 @@ impl EventTypeFlags { /// All [`EventTypeFlags`] in [`Intents::GUILD_EMOJIS_AND_STICKERS`]. /// /// [`Intents::GUILD_EMOJIS_AND_STICKERS`]: crate::Intents::GUILD_EMOJIS_AND_STICKERS - pub const GUILD_EMOJIS_AND_STICKERS: EventTypeFlags = - EventTypeFlags::from_bits_truncate( - EventTypeFlags::GUILD_EMOJIS_UPDATE.bits() - | EventTypeFlags::GUILD_STICKERS_UPDATE.bits(), - ); + pub const GUILD_EMOJIS_AND_STICKERS: EventTypeFlags = EventTypeFlags::from_bits_truncate( + EventTypeFlags::GUILD_EMOJIS_UPDATE.bits() | EventTypeFlags::GUILD_STICKERS_UPDATE.bits(), + ); /// All [`EventTypeFlags`] in [`Intents::GUILD_INTEGRATIONS`]. /// From 33623916e9eea5eaa47cd00c96d731494ad7a007 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 20:13:58 +0800 Subject: [PATCH 07/12] fix docs and tests --- cache/in-memory/src/lib.rs | 2 +- gateway/src/cluster/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 0a4f5bd25c7..07d76a15b0c 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -462,7 +462,7 @@ impl InMemoryCache { /// /// This requires the [`GUILD_EMOJIS`] intent. /// - /// [`GUILD_EMOJIS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS + /// [`GUILD_EMOJIS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS pub fn emoji( &self, emoji_id: Id, diff --git a/gateway/src/cluster/mod.rs b/gateway/src/cluster/mod.rs index 1e6c596f1f8..3f2733b401e 100644 --- a/gateway/src/cluster/mod.rs +++ b/gateway/src/cluster/mod.rs @@ -14,7 +14,7 @@ //! #[tokio::main] //! async fn main() -> Result<(), Box> { //! let token = env::var("DISCORD_TOKEN")?; -//! let intents = Intents::GUILD_BANS | Intents::GUILD_EMOJIS | Intents::GUILD_MESSAGES; +//! let intents = Intents::GUILD_BANS | Intents::GUILD_EMOJIS_AND_STICKERS | Intents::GUILD_MESSAGES; //! let (cluster, mut events) = Cluster::new(token, intents).await?; //! let cluster = Arc::new(cluster); //! cluster.up().await; From 654d6600f0e24aadc47a7b159ecd0820caa4eef7 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Tue, 8 Feb 2022 20:31:06 +0800 Subject: [PATCH 08/12] update docs again --- cache/in-memory/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 07d76a15b0c..45494c375c5 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -460,9 +460,9 @@ impl InMemoryCache { /// Gets an emoji by ID. /// - /// This requires the [`GUILD_EMOJIS`] intent. + /// This requires the [`GUILD_EMOJIS_AND_STICKERS`] intent. /// - /// [`GUILD_EMOJIS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS + /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS pub fn emoji( &self, emoji_id: Id, @@ -516,10 +516,10 @@ impl InMemoryCache { /// Gets the set of emojis in a guild. /// - /// This requires both the [`GUILDS`] and [`GUILD_EMOJIS`] intents. + /// This requires both the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] intents. /// /// [`GUILDS`]: ::twilight_model::gateway::Intents::GUILDS - /// [`GUILD_EMOJIS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS + /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS pub fn guild_emojis( &self, guild_id: Id, From ea342d90f803e43e0c0ba5006706ba2d8c228ce0 Mon Sep 17 00:00:00 2001 From: HTG-YT <39023054+HTG-YT@users.noreply.github.com> Date: Wed, 9 Feb 2022 17:47:22 +0800 Subject: [PATCH 09/12] add documentation of the intent --- cache/in-memory/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 45494c375c5..3eeb36b6fc4 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -597,10 +597,11 @@ impl InMemoryCache { /// Gets the set of the stickers in a guild. /// /// This is an O(m) operation, where m is the amount of stickers in the - /// guild. This requires the [`GUILDS`] intent and the [`STICKER`] resource - /// type. + /// guild. This requires the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] intents and the + /// [`STICKER`] resource type. /// /// [`GUILDS`]: twilight_model::gateway::Intents::GUILDS + /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS /// [`STICKER`]: crate::config::ResourceType::STICKER pub fn guild_stickers( &self, @@ -721,10 +722,11 @@ impl InMemoryCache { /// Gets a sticker by ID. /// - /// This is the O(1) operation. This requires the [`GUILDS`] intent and the - /// [`STICKER`] resource type. + /// This is the O(1) operation. This requires the [`GUILDS`] and the + /// [`GUILD_EMOJIS_AND_STICKERS`] intent and the [`STICKER`] resource type. /// /// [`GUILDS`]: twilight_model::gateway::Intents::GUILDS + /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS /// [`STICKER`]: crate::config::ResourceType::STICKER pub fn sticker( &self, From 30d03add1db0b317ed0c138026ac1eb16d3b5728 Mon Sep 17 00:00:00 2001 From: HTGAzureX1212 <39023054+HTG-YT@users.noreply.github.com> Date: Thu, 10 Feb 2022 08:30:28 +0800 Subject: [PATCH 10/12] Update cache/in-memory/src/lib.rs Co-authored-by: Cassandra McCarthy --- cache/in-memory/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 3eeb36b6fc4..9a52370f5f0 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -516,7 +516,8 @@ impl InMemoryCache { /// Gets the set of emojis in a guild. /// - /// This requires both the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] intents. + /// This requires both the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] + /// intents. /// /// [`GUILDS`]: ::twilight_model::gateway::Intents::GUILDS /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS From f6d1bceee29e796107753b20303f3c2ab66409b2 Mon Sep 17 00:00:00 2001 From: HTGAzureX1212 <39023054+HTG-YT@users.noreply.github.com> Date: Thu, 10 Feb 2022 08:31:05 +0800 Subject: [PATCH 11/12] Update cache/in-memory/src/lib.rs Co-authored-by: Cassandra McCarthy --- cache/in-memory/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 9a52370f5f0..1d8356987f2 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -598,8 +598,8 @@ impl InMemoryCache { /// Gets the set of the stickers in a guild. /// /// This is an O(m) operation, where m is the amount of stickers in the - /// guild. This requires the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] intents and the - /// [`STICKER`] resource type. + /// guild. This requires the [`GUILDS`] and [`GUILD_EMOJIS_AND_STICKERS`] + /// intents and the [`STICKER`] resource type. /// /// [`GUILDS`]: twilight_model::gateway::Intents::GUILDS /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS From 01cbe1909f0fb3e2275d8bf9b608805a34c073fb Mon Sep 17 00:00:00 2001 From: HTGAzureX1212 <39023054+HTG-YT@users.noreply.github.com> Date: Thu, 10 Feb 2022 08:31:18 +0800 Subject: [PATCH 12/12] Update cache/in-memory/src/lib.rs Co-authored-by: Cassandra McCarthy --- cache/in-memory/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache/in-memory/src/lib.rs b/cache/in-memory/src/lib.rs index 1d8356987f2..9ef102ad5e8 100644 --- a/cache/in-memory/src/lib.rs +++ b/cache/in-memory/src/lib.rs @@ -724,7 +724,7 @@ impl InMemoryCache { /// Gets a sticker by ID. /// /// This is the O(1) operation. This requires the [`GUILDS`] and the - /// [`GUILD_EMOJIS_AND_STICKERS`] intent and the [`STICKER`] resource type. + /// [`GUILD_EMOJIS_AND_STICKERS`] intents and the [`STICKER`] resource type. /// /// [`GUILDS`]: twilight_model::gateway::Intents::GUILDS /// [`GUILD_EMOJIS_AND_STICKERS`]: ::twilight_model::gateway::Intents::GUILD_EMOJIS_AND_STICKERS