Skip to content

Commit

Permalink
feat(util): add contexts to command builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Erk- committed Nov 16, 2024
1 parent 7e864ec commit fa74585
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions twilight-util/src/builder/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@
//! ```

use twilight_model::{
application::command::{
Command, CommandOption, CommandOptionChoice, CommandOptionChoiceValue, CommandOptionType,
CommandOptionValue, CommandType,
application::{
command::{
Command, CommandOption, CommandOptionChoice, CommandOptionChoiceValue,
CommandOptionType, CommandOptionValue, CommandType,
},
interaction::InteractionContextType,
},
channel::ChannelType,
guild::Permissions,
Expand Down Expand Up @@ -112,6 +115,15 @@ impl CommandBuilder {
self
}

/// Set the contexts of the command.
///
/// Defaults to nothing.
pub fn contexts(mut self, contexts: impl IntoIterator<Item = InteractionContextType>) -> Self {
self.0.contexts = Some(contexts.into_iter().collect());

self
}

/// Set the default member permission required to run the command.
///
/// Defaults to [`None`].
Expand All @@ -127,6 +139,7 @@ impl CommandBuilder {
/// Set whether the command is available in DMs.
///
/// Defaults to [`None`].
#[deprecated(note = "use contexts instead")]
#[allow(deprecated)]
pub const fn dm_permission(mut self, dm_permission: bool) -> Self {
self.0.dm_permission = Some(dm_permission);
Expand Down

0 comments on commit fa74585

Please sign in to comment.