Skip to content

Commit

Permalink
When possible, wrap an Id method instead of constructing a builder di…
Browse files Browse the repository at this point in the history
…rectly
  • Loading branch information
mkrasnitski committed Jun 20, 2022
1 parent fe9923a commit 5076f80
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ impl GuildChannel {

/// Returns a request builder that creates a [`StageInstance`] when executed.
pub fn create_stage_instance(&self) -> CreateStageInstance {
CreateStageInstance::new(self.id)
self.id.create_stage_instance()
}

/// Edits a stage instance.
Expand Down
6 changes: 3 additions & 3 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ impl Guild {
///
/// [Manage Channels]: Permissions::MANAGE_CHANNELS
pub fn create_channel(&self) -> CreateChannel {
CreateChannel::new(self.id)
self.id.create_channel()
}

/// Creates an emoji in the guild with a name and base64-encoded image. The
Expand Down Expand Up @@ -860,7 +860,7 @@ impl Guild {
///
/// [Manage Events]: Permissions::MANAGE_EVENTS
pub fn create_scheduled_event(&self) -> CreateScheduledEvent {
CreateScheduledEvent::new(self.id)
self.id.create_scheduled_event()
}

/// Returns a request builder that will create a new [`Sticker`] in the guild when executed.
Expand All @@ -869,7 +869,7 @@ impl Guild {
///
/// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS
pub fn create_sticker<'a>(&self) -> CreateSticker<'a> {
CreateSticker::new(self.id)
self.id.create_sticker()
}

/// Deletes the current guild if the current user is the owner of the
Expand Down
4 changes: 2 additions & 2 deletions src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl PartialGuild {
/// [Manage Channels]: Permissions::MANAGE_CHANNELS
#[inline]
pub fn create_channel(&self) -> CreateChannel {
CreateChannel::new(self.id)
self.id.create_channel()
}

/// Creates an emoji in the guild with a name and base64-encoded image.
Expand Down Expand Up @@ -569,7 +569,7 @@ impl PartialGuild {
///
/// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS
pub fn create_sticker<'a>(&self) -> CreateSticker<'a> {
CreateSticker::new(self.id)
self.id.create_sticker()
}

/// Deletes the current guild if the current user is the owner of the
Expand Down
6 changes: 1 addition & 5 deletions src/model/invite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ impl Invite {
/// [permission]: super::permissions
#[inline]
pub fn create(channel_id: impl Into<ChannelId>) -> CreateInvite {
CreateInvite::new(
channel_id.into(),
#[cfg(feature = "cache")]
None,
)
channel_id.into().create_invite()
}

/// Deletes the invite.
Expand Down

0 comments on commit 5076f80

Please sign in to comment.