Skip to content

Commit

Permalink
Add ignore_thread_creation to PrefixFrameworkOptions (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
seraxis authored Oct 22, 2023
1 parent 11a6948 commit bf3294d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dispatch/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ pub async fn parse_invocation<'a, U: Send + Sync, E>(
return Ok(None);
}

// Check if we can execute commands contained in thread creation messages
if msg.kind == serenity::channel::MessageType::ThreadCreated
&& framework.options.prefix_options.ignore_thread_creation
{
return Ok(None);
}

// Strip prefix, trim whitespace between prefix and rest, split rest into command name and args
let (prefix, msg_content) = match strip_prefix(framework, ctx, msg).await {
Some(x) => x,
Expand Down
3 changes: 3 additions & 0 deletions src/structs/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ pub struct PrefixFrameworkOptions<U, E> {
pub execute_self_messages: bool,
/// Whether to ignore messages from bots for command invoking. Default `true`
pub ignore_bots: bool,
/// Whether to ignore commands contained within thread creation messages. Default `true`
pub ignore_thread_creation: bool,
/// Whether command names should be compared case-insensitively.
pub case_insensitive_commands: bool,
/* // TODO: implement
Expand Down Expand Up @@ -173,6 +175,7 @@ impl<U, E> Default for PrefixFrameworkOptions<U, E> {
ignore_edits_if_not_yet_responded: false,
execute_self_messages: false,
ignore_bots: true,
ignore_thread_creation: true,
case_insensitive_commands: true,
// help_when_mentioned: true,
// help_commmand: None,
Expand Down

0 comments on commit bf3294d

Please sign in to comment.