【问题标题】:How do I make a Discord bot that change status with watching status type?如何制作一个通过观看状态类型更改状态的 Discord 机器人?
【发布时间】:2020-08-27 07:07:21
【问题描述】:
  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 状态类型中显示这个,我该怎么做?

【问题讨论】:

    标签: javascript node.js discord.js status


    【解决方案1】:

    首先查看the Discord.js documentation,它为您提供了一个直接示例:

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

    【讨论】:

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

      【讨论】:

      • 欢迎来到 Stack Overflow。 Stack Overflow 上不鼓励仅使用代码的答案,因为它们没有解释它是如何解决问题的。请编辑您的答案以解释此代码的作用以及它如何回答问题,以便它对 OP 以及其他有类似问题的用户有用。
      猜你喜欢
      • 2021-07-29
      • 2020-07-29
      • 2018-12-13
      • 2021-07-28
      • 2021-01-11
      • 2019-05-26
      • 2020-11-06
      • 2021-08-29
      • 2020-11-23
      相关资源
      最近更新 更多