【发布时间】:2020-07-09 15:42:31
【问题描述】:
您好,我正在制作一个机器人,它基本上会制作一个完整的不和谐服务器,但我只是不知道如何大规模创建频道,所以请有人告诉我
【问题讨论】:
-
您应该向我们展示您已经尝试过的内容。发布创建服务器的代码以及它应该在哪里大规模创建频道。
标签: javascript node.js bots discord discord.js
您好,我正在制作一个机器人,它基本上会制作一个完整的不和谐服务器,但我只是不知道如何大规模创建频道,所以请有人告诉我
【问题讨论】:
标签: javascript node.js bots discord discord.js
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!
【讨论】: