Quantcast
Channel: Discord.js bot looping using || or operator - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Dominik for Discord.js bot looping using || or operator

$
0
0

The statement if (message.content === '!help' || '!command') { has two blocks: message.content === '!help' and '!command'. The || or operator says: "either of those things should be true".

So it ignores the first block because the second block will always be truthy.

What you're trying to do is this:

client.on('message', (message) => {  let targetMember = message.member.user;  if (message.content === '!help' || message.content === '!command') {    message.channel.send(      `Hello ${targetMember}! This bot is currently used for testing only. Features will be added in the future, however for more info, please contact <@248030367666274304>.`    );  }});

Viewing all articles
Browse latest Browse all 2




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>