【问题标题】:How to set bot's status如何设置机器人的状态
【发布时间】:2018-08-23 12:11:12
【问题描述】:

所以我试图让我的机器人的流媒体与抑郁症有关,但我尝试了多种方法,但它们都不起作用。
我试过这些方法:

client.user.setPresence({ game: { name: 'with depression' }, status: 'online' });
bot.user.setGame('with depression', 'https://www.twitch.tv/monstercat');

这些似乎都没有按应有的方式工作。任何帮助表示赞赏。

【问题讨论】:

    标签: node.js streaming bots status discord.js


    【解决方案1】:

    使用这个:

    client.user.setActivity("with depression", {
      type: "STREAMING",
      url: "https://www.twitch.tv/monstercat"
    });
    

    【讨论】:

      【解决方案2】:

      .setGame 已停产。使用:

      client.user.setActivity("Game"); 
      

      设置游戏状态。

      另外,如果您使用的是早期版本的 discord.js,请尝试以下操作:

      client.user.setGame("Game");
      

      在较新版本的 discord.js 中,已弃用。

      【讨论】:

        【解决方案3】:

        在启动时启动消息的简单方法:

        bot.on('ready', () => {
            bot.user.setStatus('available')
            bot.user.setPresence({
                game: {
                    name: 'with depression',
                    type: "STREAMING",
                    url: "https://www.twitch.tv/monstercat"
                }
            });
        });
        

        您也可以在启动后在其他地方声明,根据需要更改消息:

        bot.user.setPresence({ game: { name: 'with depression', type: "streaming", url: "https://www.twitch.tv/monstercat"}}); 
        

        【讨论】:

          【解决方案4】:

          从 2018 年开始一直遇到这种情况,对不起,不是对不起。但对如何执行此操作提出疑问的新用户需要知道 游戏 不再适用于此任务。

          bot.user.setStatus('available')
          bot.user.setPresence({
              game: {
                  name: 'with depression',
                  type: "STREAMING",
                  url: "https://www.twitch.tv/monstercat"
              }
          }
          

          不再起作用了。您现在需要这样做:

          bot.user.setPresence({
              status: 'online',
              activity: {
                  name: 'with depression',
                  type: 'STREAMING',
                  url: 'https://www.twitch.tv/monstercat'
              }
          })
          

          这里引用它是因为“游戏”不再是 setPresence 的有效属性。读 PresenceData Documentation 了解更多信息。

          【讨论】:

            【解决方案5】:
                client.user.setStatus('dnd', 'Made by KwinkyWolf') 
            

            并将“dnd”更改为您希望它具有的任何状态。然后下一个字段“由 KwinkyWolf 制造”是您改变游戏规则的地方。希望这会有所帮助:)

            状态列表':

            • 在线
            • 空闲
            • dnd
            • 不可见

            不确定它们是否仍然相同,或者是否还有更多但希望也有帮助:)

            【讨论】:

              【解决方案6】:

              setGame 已停产。您必须使用client.user.setActivity

              不要忘记,如果您要设置直播状态,您必须指定 Twitch 网址

              这里有一个例子:

              client.user.setActivity("with depression", {
                type: "STREAMING",
                url: "https://www.twitch.tv/example-url"
              });
              

              【讨论】:

              • 它与上面的完全相同的答案。你忘了改变“抑郁症”kek
              猜你喜欢
              • 2021-07-30
              • 2020-02-10
              • 2020-12-30
              • 1970-01-01
              • 2021-05-27
              • 2021-05-07
              • 2019-01-05
              • 2021-12-31
              • 1970-01-01
              相关资源
              最近更新 更多