My bot is not replying mentions

Hi I have a question, I did a twitter bot that respond mentions

The bot is automated and I’m using a monitor. Everything ok but my problem is that the bot replies the mention when is in this format “@username [any text that you want]” but if people mentions my bot like that for example: “[any beautiful word that you want] @username” my twitter bot is not searching that, so not respond anything.

This is the code and run in nodejs:
        function random_from_array(arr){
        return arr[Math.floor(Math.random()*arr.length)]; 
    }

app.all("/", function (request, response) {

    fs.readFile(__dirname + '/last_mention_id.txt', 'utf8', function (err, last_mention_id) {
      /* First, let's load the ID of the last tweet we responded to. */
      console.log('last_mention_id:', last_mention_id);
  
      Bot.get('search/tweets', { q: 'to:' + process.env.TWITTER_HANDLE + ' -from:' + process.env.TWITTER_HANDLE, since_id: last_mention_id }, function(err, data, response) {
        if (err){
          console.log('Error!', err);
          return false;
        }
        /* Next, let's search for Tweets that mention our bot, starting after the last mention we responded to. */
        if (data.statuses.length) {
          console.log(data.statuses);
          data.statuses.forEach(function(status) {
            console.log(status.id_str);
            console.log(status.text);
            console.log(status.user.screen_name);
  
            /* Now we can respond to each tweet. */
            Bot.post('statuses/update', {
              status: '@' + status.user.screen_name + ' ' + random_from_array(sentences),
              in_reply_to_status_id: status.id_str
            }, function(err, data, response) {
              if (err){
                  /* TODO: Proper error handling? */
                console.log('Error!', err);
              }
              else{
                fs.writeFile(__dirname + '/last_mention_id.txt', status.id_str, function (err) {
                  /* TODO: Error handling? */
                  if(err){
                    console.log('Error!', err);
                  }
                });
              }
            });
          });
        } else {
          /* No new mentions since the last time we checked. */
          console.log('No new mentions...');      
        }
      });    
    });
    response.sendStatus(200);
  });

Sorry if is not in a code format. I’m new here.

Try something like:

if(message.content.includes(ID of bot)){ return msg.reply("I am here!") }

This only works if you work with discord.js

I am now known to any other language…

This will give you a short thing… Just look if the ID of the bot is included that message.

Ello, i just wanted to extend a bit more on jarvo’s tip,

here is a more clean version, that does work more reliably:

 if ( post_or_something_here.indexOf(BOT_MENTION_HERE) > 0) { reply_here }

that will check to make sure that the mention is existant, and if it is, will reply to the mention

I resolved my issue changing
Bot.get('search/tweets', { q: 'to:' + process.env.TWITTER_HANDLE + ' -from:' + process.env.TWITTER_HANDLE, since_id: last_mention_id }, function(err, data, response) {

for this
Bot.get('search/tweets', { q: '@username' , since_id: last_mention_id }, function(err, data, response) {

Now it’s looking for all the tweets that contains the user name and save the last mention in a txt file for no repeat. I’m not sure if it’s secure but it works lol

But in the Jonyk56 solution, what is “post_or_something_here” variable? I suppose that BOT_MENTION_HERE is the username, isn’t it?