The ReferenceError occurs because you’re referencing a variable condition that doesn’t exist in your code. To ensure messages containing *DD aren’t deleted, you should reverse your logic. Set up the deletion timer for all messages, but skip it when the message has *DD. Modify your code as follows:
Looking at your error, the main issue is that you’ve declared a variable called condition without actually defining it anywhere in your code. When the JavaScript engine tries to evaluate if (condition === null), it throws a ReferenceError because condition doesn’t exist. You can simply remove that entire condition check since it’s not serving any purpose. Your logic should be straightforward - only delete messages that don’t contain the *DD phrase. Also worth noting that you’re mixing up your message deletion approach. The bot.deleteMessage() method you’re using is from an older version of discord.js and might not work properly with newer versions. Consider updating to use message.delete() for better compatibility and reliability.
yeah your condition var isnt declared anywhere, hence the referenceerror. also, you shouldnt use bot.deleteMessage(), instead go for message.delete(). just check if the message doesnt have *DD before setting the timeout, way simpler!