Skip to content

Commit 8437326

Browse files
authored
Add helper for extracting a guild id from an interaction (#3070)
1 parent 2274b32 commit 8437326

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/model/application/interaction.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ impl Interaction {
6464
}
6565
}
6666

67+
/// Guild ID the interaction was sent from, if any.
68+
#[must_use]
69+
pub fn guild_id(&self) -> Option<GuildId> {
70+
match self {
71+
Self::Ping(_) => None,
72+
Self::Command(i) | Self::Autocomplete(i) => i.guild_id,
73+
Self::Component(i) => i.guild_id,
74+
Self::Modal(i) => i.guild_id,
75+
}
76+
}
77+
6778
/// Gets the interaction application Id
6879
#[must_use]
6980
pub fn application_id(&self) -> ApplicationId {

0 commit comments

Comments
 (0)