如何在 Discord.js 上批量创建频道

问题描述 投票:0回答:2

你好,我正在制作一个机器人,它基本上会制作一个完整的不和谐服务器,我只是不知道如何批量创建频道,所以有人可以告诉我吗

javascript node.js bots discord discord.js
2个回答
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!

0
投票

只需将您连接的互联网从一个 wifi 连接切换到另一个,然后尽可能快地发送“创建频道”按钮即可。

© www.soinside.com 2019 - 2024. All rights reserved.