【问题标题】:Guild in the presence of discord bot公会在不和谐机器人的存在
【发布时间】:2021-10-16 20:13:40
【问题描述】:

我试图将公会置于不和谐机器人的存在下,但我无法得到它,版本是 v12 这是我的代码。示例(查看 76 台服务器)

function presence(){
  client.user.setPresence({
     status: "online",
     activity: {
        name: "{len(bot.guilds)}",
        type: "WATCHING",
     
     }
  });
}

示例图片

【问题讨论】:

    标签: javascript bots discord.js


    【解决方案1】:

    我假设您正在尝试显示机器人所在的公会数量。

    // Discord.js v13
    client.user.setPresence({
      status: 'online',
      activities: [{
        name: `${client.guilds.cache.size} servers`,
        type: 'WATCHING'
      }]
    )
    
    // Discord.js v12
    client.user.setPresence({
      status: 'online',
      activity: {
        name: `${client.guilds.cache.size} servers`,
        type: 'WATCHING'
      }
    )
    

    或者,如果您不更改客户端的状态,您可以使用setActivity(因为它默认为online):

    client.user.setActivity(`${client.guilds.cache.size} servers`, {type: 'WATCHING'})
    

    【讨论】:

      猜你喜欢
      • 2018-03-20
      • 1970-01-01
      • 2020-07-03
      • 2020-09-23
      • 2021-10-30
      • 2021-08-05
      • 2021-05-27
      • 2021-07-15
      • 2022-01-07
      相关资源
      最近更新 更多