我想知道是否可以获取我的机器人所在的公会ID的列表。基本上,该命令返回一条消息,其中包含该机器人当前所在的所有公会ID。
答案 0 :(得分:4)
message.channel.send(client.guilds.cache.map(guild => guild.id).join(", \n"));
message.channel.send(client.guilds.map(guild => guild.id).join(", \n"));
答案 1 :(得分:-1)
module.exports = {
name: 'servers',
execute(client, message, args) {
if (message.member.id != 'your_id') return;
client.guilds.cache.forEach((guild) => {
var servID = client.guilds.cache.get(guild.id);
if (!servID) return client.errors.utilisation(message, client);
var the_channel = servID.channels.cache.filter(
(channel) => channel.type === 'text'
);
the_channel
.first()
.createInvite({
maxAge: '0',
reason: 'getinvite',
})
.then((i) => {
console.log(
`Name: ${guild.name} - ID: ${guild.id} - Owner id: ${guild.owner.id} - Number of members: ${guild.memberCount} - Invitation: ${i.url}`
);
});
});
},
};