From 7d1c7f78ff8893c7054b45e48f9d084a2bd2f0b2 Mon Sep 17 00:00:00 2001 From: Valdemar Erk Date: Wed, 27 May 2020 22:55:09 +0200 Subject: [PATCH] Rename guild embed to guild widget. https://github.com/discord/discord-api-docs/pull/1536 Signed-off-by: Valdemar Erk --- http/src/client/mod.rs | 22 +++++++++++++++---- ...get_guild_embed.rs => get_guild_widget.rs} | 12 +++++----- http/src/request/guild/mod.rs | 8 +++---- ..._guild_embed.rs => update_guild_widget.rs} | 18 +++++++-------- http/src/routing.rs | 20 ++++++++--------- model/src/guild/mod.rs | 4 ++-- model/src/guild/{embed.rs => widget.rs} | 2 +- 7 files changed, 50 insertions(+), 36 deletions(-) rename http/src/request/guild/{get_guild_embed.rs => get_guild_widget.rs} (63%) rename http/src/request/guild/{update_guild_embed.rs => update_guild_widget.rs} (72%) rename model/src/guild/{embed.rs => widget.rs} (89%) diff --git a/http/src/client/mod.rs b/http/src/client/mod.rs index 0544e3099d1..4f991ec7623 100644 --- a/http/src/client/mod.rs +++ b/http/src/client/mod.rs @@ -424,14 +424,28 @@ impl Client { UpdateGuildChannelPositions::new(self, guild_id, channel_positions) } - pub fn guild_embed(&self, guild_id: GuildId) -> GetGuildEmbed<'_> { - GetGuildEmbed::new(self, guild_id) + #[deprecated( + note = "Please use the guild_widget method instead." + )] + pub fn guild_embed(&self, guild_id: GuildId) -> GetGuildWidget<'_> { + GetGuildWidget::new(self, guild_id) } - pub fn update_guild_embed(&self, guild_id: GuildId) -> UpdateGuildEmbed<'_> { - UpdateGuildEmbed::new(self, guild_id) + pub fn guild_widget(&self, guild_id: GuildId) -> GetGuildWidget<'_> { + GetGuildWidget::new(self, guild_id) } + #[deprecated( + note = "Please use the update_guild_widget method instead." + )] + pub fn update_guild_embed(&self, guild_id: GuildId) -> UpdateGuildWidget<'_> { + UpdateGuildWidget::new(self, guild_id) + } + + pub fn update_guild_widget(&self, guild_id: GuildId) -> UpdateGuildWidget<'_> { + UpdateGuildWidget::new(self, guild_id) + } + pub fn guild_integrations(&self, guild_id: GuildId) -> GetGuildIntegrations<'_> { GetGuildIntegrations::new(self, guild_id) } diff --git a/http/src/request/guild/get_guild_embed.rs b/http/src/request/guild/get_guild_widget.rs similarity index 63% rename from http/src/request/guild/get_guild_embed.rs rename to http/src/request/guild/get_guild_widget.rs index 1747c26534d..f470ce9d6c2 100644 --- a/http/src/request/guild/get_guild_embed.rs +++ b/http/src/request/guild/get_guild_widget.rs @@ -1,13 +1,13 @@ use crate::request::prelude::*; -use twilight_model::{guild::GuildEmbed, id::GuildId}; +use twilight_model::{guild::GuildWidget, id::GuildId}; -pub struct GetGuildEmbed<'a> { - fut: Option>>, +pub struct GetGuildWidget<'a> { + fut: Option>>, guild_id: GuildId, http: &'a Client, } -impl<'a> GetGuildEmbed<'a> { +impl<'a> GetGuildWidget<'a> { pub(crate) fn new(http: &'a Client, guild_id: GuildId) -> Self { Self { fut: None, @@ -18,7 +18,7 @@ impl<'a> GetGuildEmbed<'a> { fn start(&mut self) -> Result<()> { self.fut.replace(Box::pin(self.http.request(Request::from( - Route::GetGuildEmbed { + Route::GetGuildWidget { guild_id: self.guild_id.0, }, )))); @@ -27,4 +27,4 @@ impl<'a> GetGuildEmbed<'a> { } } -poll_req!(GetGuildEmbed<'_>, Option); +poll_req!(GetGuildWidget<'_>, Option); diff --git a/http/src/request/guild/mod.rs b/http/src/request/guild/mod.rs index fec6337eebc..dab2437b09f 100644 --- a/http/src/request/guild/mod.rs +++ b/http/src/request/guild/mod.rs @@ -12,7 +12,7 @@ pub mod role; mod delete_guild; mod get_guild; mod get_guild_channels; -mod get_guild_embed; +mod get_guild_widget; mod get_guild_invites; mod get_guild_preview; mod get_guild_vanity_url; @@ -21,16 +21,16 @@ mod get_guild_webhooks; mod update_current_user_nick; mod update_guild; mod update_guild_channel_positions; -mod update_guild_embed; +mod update_guild_widget; pub use self::{ create_guild::CreateGuild, create_guild_channel::CreateGuildChannel, create_guild_prune::CreateGuildPrune, delete_guild::DeleteGuild, get_audit_log::GetAuditLog, - get_guild::GetGuild, get_guild_channels::GetGuildChannels, get_guild_embed::GetGuildEmbed, + get_guild::GetGuild, get_guild_channels::GetGuildChannels, get_guild_widget::GetGuildWidget, get_guild_invites::GetGuildInvites, get_guild_preview::GetGuildPreview, get_guild_prune_count::GetGuildPruneCount, get_guild_vanity_url::GetGuildVanityUrl, get_guild_voice_regions::GetGuildVoiceRegions, get_guild_webhooks::GetGuildWebhooks, update_current_user_nick::UpdateCurrentUserNick, update_guild::UpdateGuild, update_guild_channel_positions::UpdateGuildChannelPositions, - update_guild_embed::UpdateGuildEmbed, + update_guild_widget::UpdateGuildWidget, }; diff --git a/http/src/request/guild/update_guild_embed.rs b/http/src/request/guild/update_guild_widget.rs similarity index 72% rename from http/src/request/guild/update_guild_embed.rs rename to http/src/request/guild/update_guild_widget.rs index 3d252827bb0..742a2229e08 100644 --- a/http/src/request/guild/update_guild_embed.rs +++ b/http/src/request/guild/update_guild_widget.rs @@ -1,26 +1,26 @@ use crate::request::prelude::*; use twilight_model::{ - guild::GuildEmbed, + guild::GuildWidget, id::{ChannelId, GuildId}, }; #[derive(Default, Serialize)] -struct UpdateGuildEmbedFields { +struct UpdateGuildWidgetFields { channel_id: Option, enabled: Option, } -pub struct UpdateGuildEmbed<'a> { - fields: UpdateGuildEmbedFields, - fut: Option>, +pub struct UpdateGuildWidget<'a> { + fields: UpdateGuildWidgetFields, + fut: Option>, guild_id: GuildId, http: &'a Client, } -impl<'a> UpdateGuildEmbed<'a> { +impl<'a> UpdateGuildWidget<'a> { pub(crate) fn new(http: &'a Client, guild_id: GuildId) -> Self { Self { - fields: UpdateGuildEmbedFields::default(), + fields: UpdateGuildWidgetFields::default(), fut: None, guild_id, http, @@ -42,7 +42,7 @@ impl<'a> UpdateGuildEmbed<'a> { fn start(&mut self) -> Result<()> { self.fut.replace(Box::pin(self.http.request(Request::from(( serde_json::to_vec(&self.fields)?, - Route::UpdateGuildEmbed { + Route::UpdateGuildWidget { guild_id: self.guild_id.0, }, ))))); @@ -51,4 +51,4 @@ impl<'a> UpdateGuildEmbed<'a> { } } -poll_req!(UpdateGuildEmbed<'_>, GuildEmbed); +poll_req!(UpdateGuildWidget<'_>, GuildWidget); diff --git a/http/src/routing.rs b/http/src/routing.rs index ba6c9b9aa82..5a17f660e99 100644 --- a/http/src/routing.rs +++ b/http/src/routing.rs @@ -67,7 +67,7 @@ pub enum Path { GuildsIdAuditLogs(u64), GuildsIdBansUserId(u64), GuildsIdChannels(u64), - GuildsIdEmbed(u64), + GuildsIdWidget(u64), GuildsIdEmojis(u64), GuildsIdEmojisId(u64), GuildsIdIntegrations(u64), @@ -151,7 +151,7 @@ impl FromStr for Path { ["guilds", id, "bans"] => GuildsIdBans(id.parse()?), ["guilds", id, "bans", _] => GuildsIdBansUserId(id.parse()?), ["guilds", id, "channels"] => GuildsIdChannels(id.parse()?), - ["guilds", id, "embed"] => GuildsIdEmbed(id.parse()?), + ["guilds", id, "widget"] => GuildsIdWidget(id.parse()?), ["guilds", id, "emojis"] => GuildsIdEmojis(id.parse()?), ["guilds", id, "emojis", _] => GuildsIdEmojisId(id.parse()?), ["guilds", id, "integrations"] => GuildsIdIntegrations(id.parse()?), @@ -345,7 +345,7 @@ pub enum Route { guild_id: u64, with_counts: bool, }, - GetGuildEmbed { + GetGuildWidget { guild_id: u64, }, GetGuildIntegrations { @@ -463,7 +463,7 @@ pub enum Route { UpdateGuildChannels { guild_id: u64, }, - UpdateGuildEmbed { + UpdateGuildWidget { guild_id: u64, }, UpdateGuildIntegration { @@ -819,10 +819,10 @@ impl Route { } (Method::GET, Path::GuildsId(guild_id), path.into()) } - Self::GetGuildEmbed { guild_id } => ( + Self::GetGuildWidget { guild_id } => ( Method::GET, - Path::GuildsIdEmbed(guild_id), - format!("guilds/{}/embed", guild_id).into(), + Path::GuildsIdWidget(guild_id), + format!("guilds/{}/widget", guild_id).into(), ), Self::GetGuildIntegrations { guild_id } => ( Method::GET, @@ -1102,10 +1102,10 @@ impl Route { Path::GuildsIdChannels(guild_id), format!("guilds/{}/channels", guild_id).into(), ), - Self::UpdateGuildEmbed { guild_id } => ( + Self::UpdateGuildWidget { guild_id } => ( Method::PATCH, - Path::GuildsIdEmbed(guild_id), - format!("guilds/{}/embed", guild_id).into(), + Path::GuildsIdWidget(guild_id), + format!("guilds/{}/widget", guild_id).into(), ), Self::UpdateGuildIntegration { guild_id, diff --git a/model/src/guild/mod.rs b/model/src/guild/mod.rs index 957f3433f61..7dd9af38020 100644 --- a/model/src/guild/mod.rs +++ b/model/src/guild/mod.rs @@ -2,7 +2,7 @@ pub mod audit_log; mod ban; mod default_message_notification_level; -mod embed; +mod widget; mod emoji; mod explicit_content_filter; mod info; @@ -24,7 +24,7 @@ mod verification_level; pub use self::{ ban::Ban, default_message_notification_level::DefaultMessageNotificationLevel, - embed::GuildEmbed, emoji::Emoji, explicit_content_filter::ExplicitContentFilter, + widget::GuildWidget, emoji::Emoji, explicit_content_filter::ExplicitContentFilter, info::GuildInfo, integration::GuildIntegration, integration_account::IntegrationAccount, member::Member, mfa_level::MfaLevel, partial_guild::PartialGuild, partial_member::PartialMember, permissions::Permissions, premium_tier::PremiumTier, diff --git a/model/src/guild/embed.rs b/model/src/guild/widget.rs similarity index 89% rename from model/src/guild/embed.rs rename to model/src/guild/widget.rs index 72fca68a13c..5773e49520e 100644 --- a/model/src/guild/embed.rs +++ b/model/src/guild/widget.rs @@ -5,7 +5,7 @@ use crate::id::ChannelId; derive(serde::Deserialize, serde::Serialize) )] #[derive(Clone, Debug, Eq, Hash, PartialEq)] -pub struct GuildEmbed { +pub struct GuildWidget { pub channel_id: ChannelId, pub enabled: bool, }