Как массово создавать каналы на Discord. js - PullRequest
0 голосов
/ 09 июля 2020

Здравствуйте, я делаю бота, который в основном будет создавать целый сервер Discord, и я просто не могу понять, как массово создавать каналы, чтобы кто-нибудь сказал мне, пожалуйста

1 Ответ

1 голос
/ 09 июля 2020
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!
...