Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Context::guild_channel() #208

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/structs/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ context_methods! {
}
}

/// Return the guild channel of this context, if we are inside a guild.
#[cfg(feature = "cache")]
await (guild_channel self)
(pub async fn guild_channel(self) -> Option<serenity::GuildChannel>) {
if let Ok(serenity::Channel::Guild(guild_channel)) = self.channel_id().to_channel(self.serenity_context()).await {
return Some(guild_channel);
}
None
}

// Doesn't fit in with the rest of the functions here but it's convenient
/// Return the guild of this context, if we are inside a guild.
///
Expand Down