Skip to content

Commit

Permalink
Remove Option around Interaction::app_permissions (#3034)
Browse files Browse the repository at this point in the history
Discord documents this as always present, even with Ping interactions.
  • Loading branch information
GnomedDev committed Nov 15, 2024
1 parent e9238dd commit efb5820
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/model/application/command_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ pub struct CommandInteraction {
/// Always `1`.
pub version: u8,
/// Permissions the app or bot has within the channel the interaction was sent from.
// TODO(next): This is now always serialized.
pub app_permissions: Option<Permissions>,
pub app_permissions: Permissions,
/// The selected language of the invoking user.
pub locale: FixedString,
/// The guild's preferred locale.
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/component_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct ComponentInteraction {
/// The message this interaction was triggered by, if it is a component.
pub message: Box<Message>,
/// Permissions the app or bot has within the channel the interaction was sent from.
pub app_permissions: Option<Permissions>,
pub app_permissions: Permissions,
/// The selected language of the invoking user.
pub locale: FixedString,
/// The guild's preferred locale.
Expand Down
4 changes: 2 additions & 2 deletions src/model/application/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ impl Interaction {

/// Permissions the app or bot has within the channel the interaction was sent from.
#[must_use]
pub fn app_permissions(&self) -> Option<Permissions> {
pub fn app_permissions(&self) -> Permissions {
match self {
Self::Ping(_) => None,
Self::Ping(i) => i.app_permissions,
Self::Command(i) | Self::Autocomplete(i) => i.app_permissions,
Self::Component(i) => i.app_permissions,
Self::Modal(i) => i.app_permissions,
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/modal_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ModalInteraction {
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<Box<Message>>,
/// Permissions the app or bot has within the channel the interaction was sent from.
pub app_permissions: Option<Permissions>,
pub app_permissions: Permissions,
/// The selected language of the invoking user.
pub locale: FixedString,
/// The guild's preferred locale.
Expand Down
2 changes: 2 additions & 0 deletions src/model/application/ping_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ pub struct PingInteraction {
pub token: FixedString,
/// Always `1`.
pub version: u8,
/// Permissions the app or bot has within the channel the interaction was sent from.
pub app_permissions: Permissions,
}

0 comments on commit efb5820

Please sign in to comment.