Skip to content

Bot responds 4 times #9564

Closed Answered by Vaibhav-Naik-26
neurlnet asked this question in Q&A
May 12, 2023 · 4 comments · 1 reply
Discussion options

You must be logged in to vote
client.on('messageCreate', (message) => {
  if (message.author.bot) return;
  console.log("message received!");

  const joe = message.content.toLowerCase();

  if (joe.startsWith(`what`, 0) || joe.startsWith('which', 0) || joe.startsWith('how', 0) || joe.startsWith('why', 0) || joe.startsWith('where', 0)) {
    const responses = ["I don't know!", "Use /chat to get your answer", "I'm not sure!", "Why not?", "Because why not?", "I don't care", "Find it out on your own", "No", "Nothing", "Anything can be the answer!"]
   
    const response = responses[Math.floor(Math.random() * 10)]; // I put it in a different variable because you were calculating 2 times which was resulting in 2 different…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BenjammingKirby
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by neurlnet
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants