【问题标题】:discord.js v14 trying to do that my bot status will be the amount of servers that the bot is in themdiscord.js v14 试图做到这一点我的机器人状态将是机器人在其中的服务器数量
【发布时间】:2022-09-23 00:43:05
【问题描述】:

我正在尝试这样做,我的机器人状态将是他在其中的服务器数量。

我试过了:

client.on(\"ready\", () => {
    // let guildsCount = client.guilds.size
  client.user.setPresence({
    activities: [
      { name: `${client.guilds.size} Servers!`, type: ActivityType.Watching },
    ],
    status: \"online\",
  });
});

它在说观看未定义的服务器!

我也试过:

let guildsCount = client.guilds.cache.map(guild => guild.);

但是我不知道在“。”之后该怎么做才能获得公会的数量 我也试过:

let guildsCount = client.guilds.cache.get()

但它也没有工作 说看未定义

  • 试试client.guilds.cache.size。相关链接:here
  • ty client.guilds.cache.size 工作!

标签: javascript node.js discord discord.js


【解决方案1】:

client.guilds.size将返回给你不明确的.你应该使用client.guilds.cache.size

【讨论】:

    猜你喜欢
    • 2022-11-11
    • 2022-01-07
    • 2022-11-11
    • 2021-04-03
    • 2022-01-25
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2021-02-07
    相关资源
    最近更新 更多