我如何获得我的不和谐机器人所在的公会列表?

时间:2020-07-18 18:44:05

标签: node.js discord.js

我想知道是否可以获取我的机器人所在的公会ID的列表。基本上,该命令返回一条消息,其中包含该机器人当前所在的所有公会ID。

2 个答案:

答案 0 :(得分:4)

Discord JS v12

message.channel.send(client.guilds.cache.map(guild => guild.id).join(", \n"));

Discord JS v11

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}`
     );
    });
  });
 },
};