Home node.js How to set the status bot Discord?

How to set the status bot Discord?

Author

Date

Category

Recently began writing a bot for Discord and study Discord.js in parallel.
Constantly seeing bots with the status “Plays in / Help” or “Looks at N Servers”


So, how to do it on discord.js 12.2.0 ?!


Answer 1

You can use the setPresence

const discord = require ('discord.js');
Const Client = New discord.client ();
const prefix = '?';
Const Token = Require ('./ token.json'). Token;
client.on ('Ready', () = & gt; {
  Console.log (`Bot Is Ready`);
  Client.user.SetPresence ({
    Status: 'Online',
    Activity: {
      Type: 'Watching',
      Name: '/ Help',
    },
  });
});

Answer 2

Plays in “/ Help”:

bot.user.setpresence ({
  Game: {
    Name: `Plays $ {Prefix} Help`
    Type: "Playing",
  }
});

Looks at N Servers:

bot.user.setpresence ({
    Game: {
      Name: $ {bot.guilds.cache.size} servers`
      Type: "Watching",
    }
  });
});

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions