如何使Discord机器人通过观看状态类型更改状态?

时间:2019-12-10 16:36:05

标签: javascript node.js discord.js status

  const activities_list = [
  "happy holidays!❄️", 
  "happy holidays!?",
  "happy holidays!?", 
  "happy holidays!⛄"
  ];

  bot.on('ready', () => {
      setInterval(() => {
          const index = Math.floor(Math.random() * (activities_list.length - 1) + 1); 
          bot.user.setActivity(activities_list[index]);
      }, 30000); 
    });

但是我想在WATCHING状态类型中显示它,我该怎么做?

2 个答案:

答案 0 :(得分:0)

首先查看the Discord.js documentation,这是您所追求的一个直接例子:

client.user.setActivity('YouTube', { type: 'WATCHING' })

答案 1 :(得分:0)

bot.on('ready', () => {
      setInterval(() => {
          const index = Math.floor(Math.random() * (activities_list.length - 1) + 1); 
          bot.user.setActivity(activities_list[index], {type: 'Watching'});
      }, 30000); 
    });