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 ignore_thread_creation to PrefixFrameworkOptions #211

Merged
merged 1 commit into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
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
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
Loading