'How do I check if a message DOES NOT start with the prefix?
Title mostly says it all, how do I check if a message doesn't start with the prefix so I can send a message alerting the user they didn't use the prefix?
Solution 1:[1]
This answer is similar to Gh0st's answer but he had a syntax error in his code
const prefix = "!" //or whatever you want
//your msg listener will be here
if(!message.content.startsWith(prefix)) {
//do stuff here
}
Solution 2:[2]
if (!message.content.startsWith("prefix") return; // "prefix" as your prefix
This checks if the message's content starts with the prefix you put in. If it doesn't, it will ignore the message.
Solution 3:[3]
Use this:
const prefix = '!' // or whatever yours is
//inside message listener
if (!message.content.startsWith(prefix) {
// do something
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Retro |
| Solution 2 | Tyler2P |
| Solution 3 |
