如何列出我的机器人所在的所有公会及其各自的ID

时间:2020-03-25 20:21:10

标签: javascript bots discord discord.js

试图在15分钟内解决这个问题,但没有成功

代码:

client.on('ready', () => {
    client.user.setActivity('you type commands uwu', { type: 'WATCHING' });
    console.log(`${client.user.username} is fully active.`);
    console.log(`${client.guilds}`)
})

现在我只是想获取ID,但是我需要两者,这真是很烦人

1 个答案:

答案 0 :(得分:2)

您可以公会集会。

client.on('ready', () => {
    client.user.setActivity('you type commands uwu', { type: 'WATCHING' });
    console.log(`${client.user.username} is fully active.`);
    let guilds = client.guilds.cache.map(guild => guild.id) // for discord v11 //let guilds = client.guilds.map(guild => guild.id)
    console.log(guilds)
})