0

I have a discord bot, basically when the API returns "here it is" it sends a message but now the API changed and it sends "here it is" but it also sends random messages like: {int:randomnumbers} here it is

But the problem with my bot is that it checks if it only sends "here it is" but now with the random numbers it just doesn't work, could you guys please help me on that one and tell me how can I make it so if it contains "here it is" it sends the message?

function ping(){
  console.log("Pinged!");

  for(let i in config.GAME_SERVERS){
    const gameServer = config.GAME_SERVERS[i];
    axios.get(config.API_URL+gameServer)
    .then(response =>{
      if(response.data === "here it is"){
        for(let j in config.LOGGING_CHANNEL_IDS){
          sendModMessage(gameServer,config.LOGGING_CHANNEL_IDS[j]);
        }
      }
    })
    .catch(err =>{
      console.log(err);
    });
  }
}
Pointy
  • 405,095
  • 59
  • 585
  • 614
RazenBlast
  • 11
  • 1
  • 4
    Duplicate of [How to check whether a string contains a substring in JavaScript?](https://stackoverflow.com/questions/1789945/how-to-check-whether-a-string-contains-a-substring-in-javascript) – Guy Incognito Dec 07 '20 at 19:49
  • So in some cases it sends a string and in others an object? – epascarello Dec 07 '20 at 19:57
  • So what is it supposed to do when it gets a random number? You are only checking for the string. – epascarello Dec 07 '20 at 20:01

1 Answers1

-2

Try response.data.includes("here it is") as the condition in the if statement.