the title is pretty self-explanatory. Tried messing around with diff iterations of the below code. This version recognizes firstPrefix, but not secondPrefix. I just want my djs bot to be able to recognize both prefixes and run the Args split accordingly.
const firstPrefix = '!test ';
const secondPrefix = '!testtwo ';
//Prefix
bot.on('message', message => {
message.content = message.content.toLowerCase();
if (message.author.bot || !message.content.startsWith(firstPrefix || secondPrefix)) {
return;
}
//Args split
if (message.content.startsWith(firstPrefix)) {
console.log("A")
var args = message.content.slice(firstPrefix.length).split(/ +/);
}
else if (message.content.startsWith(secondPrefix)) {
console.log("B")
var args = message.content.slice(secondPrefix.length).split(/ +/);
}
I've tried doing:
if (message.author.bot || !message.content.startsWith(firstPrefix) || !message.content.startsWith(secondPrefix))
But that didn't work at all. Pretty stumped here, any help would be great. Thanks.
Your current code (second code block) will not work, as if it starts with one prefix, it does not start with the other prefix, causing it to result in a true if statement, and does not execute your command.
In the first code block, since both
firstPrefix
andsecondPrefix
are defined with values,firstPrefix || secondPrefix
will evaluate tofirstPrefix
.Since you want to include both
firstPrefix
ANDsecondPrefix
, you should do something like this: