Skip to content

How to use Message Create Collector ? #1076

Closed Answered by valzargaming
anggi117 asked this question in Q&A
Discussion options

You must be logged in to vote

This function is not actually utilized anywhere within the library, but I believe it was created with the intention to make it easy to look for messages within a channel that contain certain features without having to worry about the loop running for too long and blocking the thread. I've never actually seen it used before and I don't know why you would ever want to use it instead of calling ->filter directly unless you had a lot of messages in the collection you're searching through.

$collection = $channels->messages->filter(function (Message $message)
{
  return str_contains($message->content, 'hello'); // Adds $message to $collection if it has hello in the content
});

As for why your v…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by valzargaming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question awaiting confirmation The issue has been resolved, but awaits confirmation from the creator to confirm.
2 participants
Converted from issue

This discussion was converted from issue #772 on March 22, 2023 18:28.