简体   繁体   中英

How to change the status of a Discord.js bot?

I want to change the status of my Discord bot. I tried the one below, but it didn't work.

const { Client, MessageAttachment } = require('discord.js');

const client = new Client();

client.once('ready', () => {
 console.log('Status:Ready');
 client.user.setPresence({
  game: {
   name: 'to radio',
   type: 'LISTENING',
  },
  status: 'online',
 });
});

you can with this line

client.user.setActivity('your status', {
 type: 'a type like STREAMING',
 url: 'url of streaming',
});

You can use client.user.setActivity . The first parameter in this method is what you want the name of your activity to be.

In the second parameter, you can specify what activity type you want in your status ( WATCHING , PLAYING , STREAMING , and LISTENING ). For example:

client.on("ready", () => {
  // Playing in my support server
  client.user.setActivity("in my support server", { type: "PLAYING" });

  // Streaming <name of stream>
  client.user.setActivity({ type: "STREAMING", url: "<twich url>" });

  // Watching over xx servers
  client.user.setActivity(`over ${client.guilds.cache.size} servers`, {
    type: "WATCHING",
  });

  // Listening to xxx users
  client.user.setActivity(
    `to ${client.guilds.cache
      .map((guild) => guild.memberCount)
      .reduce((p, c) => p + c)} users`,
    { type: "LISTENING" }
  );
});
´´´
client.once('ready', () => {
    client.user.setActivity('something',{type: 'PLAYING'});
});
´´´

this is probably the easiest way to do it, the types of the presence can be PLAYING, WATCHING and STREAMING, but you can add a url to the last two.

client.once('ready', () => {
    client.user.setActivity('something',{type: 'PLAYING'});
});

can be PLAYING STREAMING WATCHING

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM