Skip to content

Commit

Permalink
Rename guild embed to guild widget.
Browse files Browse the repository at this point in the history
discord/discord-api-docs#1536

Signed-off-by: Valdemar Erk <valdemar@erk.io>
  • Loading branch information
Erk- committed May 27, 2020
1 parent a3c8547 commit 7d1c7f7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
22 changes: 18 additions & 4 deletions http/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Pending<'a, Option<GuildEmbed>>>,
pub struct GetGuildWidget<'a> {
fut: Option<Pending<'a, Option<GuildWidget>>>,
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,
Expand All @@ -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,
},
))));
Expand All @@ -27,4 +27,4 @@ impl<'a> GetGuildEmbed<'a> {
}
}

poll_req!(GetGuildEmbed<'_>, Option<GuildEmbed>);
poll_req!(GetGuildWidget<'_>, Option<GuildWidget>);
8 changes: 4 additions & 4 deletions http/src/request/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};
Original file line number Diff line number Diff line change
@@ -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<ChannelId>,
enabled: Option<bool>,
}

pub struct UpdateGuildEmbed<'a> {
fields: UpdateGuildEmbedFields,
fut: Option<Pending<'a, GuildEmbed>>,
pub struct UpdateGuildWidget<'a> {
fields: UpdateGuildWidgetFields,
fut: Option<Pending<'a, GuildWidget>>,
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,
Expand All @@ -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,
},
)))));
Expand All @@ -51,4 +51,4 @@ impl<'a> UpdateGuildEmbed<'a> {
}
}

poll_req!(UpdateGuildEmbed<'_>, GuildEmbed);
poll_req!(UpdateGuildWidget<'_>, GuildWidget);
20 changes: 10 additions & 10 deletions http/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub enum Path {
GuildsIdAuditLogs(u64),
GuildsIdBansUserId(u64),
GuildsIdChannels(u64),
GuildsIdEmbed(u64),
GuildsIdWidget(u64),
GuildsIdEmojis(u64),
GuildsIdEmojisId(u64),
GuildsIdIntegrations(u64),
Expand Down Expand Up @@ -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()?),
Expand Down Expand Up @@ -345,7 +345,7 @@ pub enum Route {
guild_id: u64,
with_counts: bool,
},
GetGuildEmbed {
GetGuildWidget {
guild_id: u64,
},
GetGuildIntegrations {
Expand Down Expand Up @@ -463,7 +463,7 @@ pub enum Route {
UpdateGuildChannels {
guild_id: u64,
},
UpdateGuildEmbed {
UpdateGuildWidget {
guild_id: u64,
},
UpdateGuildIntegration {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions model/src/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion model/src/guild/embed.rs → model/src/guild/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit 7d1c7f7

Please sign in to comment.