title: Search a given discord channel for all messages that satisfies the condition and delete
body: <p>I was trying to make a code that will check all messages in a channel for messages that contain certain words, and delete them if it does contain them. So something like:</p>
  
  <pre><code>if(msg.content.startsWith(prefix+'clean') {
    let check = msg.content.split(prefix+'clean')[1]; // Condition, in this case if it containts a certain string
    msg.channel.fetchMessages().then(msgs =&gt; { // Get messages to check
      let msglog = msgs.array() // Make an array with all the messages fetched
      for(var i = 0; i &lt; msglog.size; i++) { // Loop to check all messages in array
        if (check in msglog[i]) {
          // Code to delete that message
        };
      };
    });
  };
  </code></pre>
  
  <p>I am aware that this will not check the entire channel and it will only check the last 50 messages, but I do not know how to make it check the whole channel so this will do until I find out how to do that. </p>
  
  <p>But what code would delete the message that passes the check? Or any different way I could approach this?</p>
  
  <p>Edit:</p>
  
  <p>It seems I was not clear enough, so let's say a channel has the following conversation:</p>
  
  <p>Person A: Hi, guys!</p>
  
  <p>Person B: Hi</p>
  
  <p>Person C: Bye</p>
  
  <p>Let's say I want to delete all the messages with "Hi" in it through my bot, how should I do this? Note: I do not with to delete a message right after it has been sent, I only want to delete it when I want to do so.</p>