Jump to content

Node.js Discord Bot - Creating 50 text and voice channels (mass-creating)


Recommended Posts

Here's an example of a Discord bot in Node.js that can mass-create 50 text and voice channels with a specified text as their names:

Quote

 


const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '/'; // Command prefix

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}`);
});

client.on('message', (message) => {
  if (!message.content.startsWith(prefix) || message.author.bot) return;

  const args = message.content.slice(prefix.length).trim().split(' ');
  const command = args.shift().toLowerCase();

  if (command === 'createchannels') {
    if (!message.member.hasPermission('MANAGE_CHANNELS')) {
      return message.reply('You do not have permission to use this command.');
    }

    // Create 50 text channels
    for (let i = 1; i <= 50; i++) {
      message.guild.channels.create(`text-channel-${i}`, {
        type: 'text',
        reason: 'Creating mass text channels',
        topic: 'Powered by www.easy-code.ro',
      })
        .then((channel) => console.log(`Created text channel: ${channel.name}`))
        .catch((error) => console.error('Error creating text channel:', error));
    }

    // Create 50 voice channels
    for (let i = 1; i <= 50; i++) {
      message.guild.channels.create(`voice-channel-${i}`, {
        type: 'voice',
        reason: 'Creating mass voice channels',
        bitrate: 64, // Adjust the bitrate as desired
      })
        .then((channel) => console.log(`Created voice channel: ${channel.name}`))
        .catch((error) => console.error('Error creating voice channel:', error));
    }

    message.reply('Successfully created mass channels.');
  }
});

client.login('YOUR_BOT_TOKEN');

 

In this example, when you run the bot and send the command `/createchannels`, it will create 50 text channels and 50 voice channels in the server. Each text channel will have a name in the format `text-channel-{number}` (e.g., `text-channel-1`, `text-channel-2`, etc.), and each voice channel will have a name in the format `voice-channel-{number}` (e.g., `voice-channel-1`, `voice-channel-2`, etc.). Additionally, the text channels will have the topic set as "Powered by www.easy-code.ro".

Remember to replace `'YOUR_BOT_TOKEN'` with your actual bot token, obtained from the Discord Developer Portal.

Please note that mass-creating a large number of channels can be resource-intensive and may cause rate limits or performance issues. Be cautious when using this functionality and ensure it complies with Discord's guidelines and best practices.

soundcloud" Icon - Download for free – Iconduck ilyhiryu

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

Board Life Status


Board startup date: October 22, 2021 17:08:30


×
×
  • Create New...