Reputation: 85
what it does is add a reaction :pray:
when an embed has footer.text
, but I don't want that, I want it to react when it doesn't have a footer.text
if(message.embeds.length >= 0)
// Check if the Message has embed or not
{
let embed = message.embeds
// console.log(embed) just a console.log
for(let i = 0; i < embed.length; i++)
// Loop it since in v13 you can send multiple embed in single message
{
if (!embed[i] || !embed[i].footer || embed[i].footer.text === null) return;
// check each embed if it has footer.text or not, if it doesnt then do nothing
{
setTimeout(function(){
message.react(':pray:')
}, 1000);
}
}
}
Upvotes: 2
Views: 29
Reputation: 2286
You simply need to switch your conditions like so:
if (embed[i] || embed[i].footer || embed[i].footer.text !== null) {
setTimeout(function() {
message.react('🙏')
}, 1000);
}
Where !==
represents Strict Inequality
so what you are actually doing is checking the following conditions
Further since all of these conditions are necessary I would suggest using Logical AND (&&)
operator which only returns true if the checks of all operands are fulfilled, so your code would look something like this:
if (embed[i] && embed[i].footer && embed[i].footer.text !== null) {
setTimeout(function() {
message.react('🙏')
}, 1000);
}
Upvotes: 1