【问题标题】:How do you mass create channels on Discord.js你如何在 Discord.js 上批量创建频道
【发布时间】:2020-07-09 15:42:31
【问题描述】:

您好,我正在制作一个机器人,它基本上会制作一个完整的不和谐服务器,但我只是不知道如何大规模创建频道,所以请有人告诉我

【问题讨论】:

  • 您应该向我们展示您已经尝试过的内容。发布创建服务器的代码以及它应该在哪里大规模创建频道。

标签: javascript node.js bots discord discord.js


【解决方案1】:
const Channels = ["Example Channel", "Example Channel 2"]; // Example of channel names.
const Guild = await client.guilds.create("My Guild"); // Creating the guild.

Channels.forEach(channelName => { // Looping through Channels array to get the channels names.
    Guild.channels.create(channelName); // Creating the channels.
});

const GuildChannel = Guild.channels.cache.filter(c => c.type === "text").find(x => x.position == 0); // Getting the first channel in the guild.
const Invite = await GuildChannel.createInvite({maxAge: 0, maxUses: 1}); // Creating and invite.
message.channel.send(`I created the guild ${Guild.name}. Invite Link: ${Invite.url}`); // Sending the invite link to the current channel.

// Warning: client.guilds.create() is only available to bots in fewer than 10 guilds.guilds!

【讨论】:

  • 您使用的是哪个版本的 Discord.js?
  • 我很确定这是您的节点版本,因为最新的 Discord.js 版本是 12.2.0。另外,我认为您的代码中的其他内容导致了错误。
猜你喜欢
  • 2020-09-19
  • 1970-01-01
  • 2023-03-27
  • 2021-04-04
  • 1970-01-01
  • 2020-04-24
  • 2021-05-04
  • 2021-10-12
  • 2020-06-23
相关资源
最近更新 更多