Back to Blog
tutorial•7 min read

AI Discord Bot Maker: Build a Bot with Slash Commands (2026)

AI discord bot maker guide: build a Discord.js v14 bot with slash commands and moderation, set intents, register commands and deploy it.

Marco N.
October 31, 2026
AI Discord Bot Maker: Build a Bot with Slash Commands (2026)

AI Discord Bot Maker: Build a Bot with Slash Commands (2026)

A Discord bot is a program that logs in with a token and reacts to events. A user runs a slash command, a message is posted, or a member joins the server. An AI discord bot maker can write the starting code for that program, but you still need to understand its parts, so you can test the output and fix what does not work. This guide builds a small bot with Discord.js v14. It has a /ping command, a /kick command for moderators, and a deploy script that registers the commands.

What you need before you start

  1. Node.js 18 or newer. Check the version with node -v.
  2. A Discord account and a test server that you own.
  3. A code editor and a terminal.
  4. Basic JavaScript knowledge. You do not need to be an expert.

Step 1: Create the application and the bot

  1. Open the Discord Developer Portal and create a new application.
  2. Open the Bot section and click Reset Token. Copy the token once and store it in a .env file. Never share it in a chat, a screenshot or a public repository. If it leaks, reset it immediately.
  3. Enable privileged intents only if your code uses them. Server Members Intent is needed for events such as a member joining. Message Content Intent is needed to read the text of normal messages. The examples here use slash commands, so neither is required.
  4. Open OAuth2, then URL Generator. Select the scopes bot and applications.commands, choose the permissions the bot needs (for example Kick Members), and open the generated link to invite the bot to your test server.

Intents tell Discord which events your bot receives. Request only the ones you use. The bot stays lighter and handles less data.

Step 2: Set up the project

mkdir discord-mod-bot
cd discord-mod-bot
npm init -y
npm install discord.js dotenv

Create a .env file in the project folder:

DISCORD_TOKEN=your-bot-token
CLIENT_ID=your-application-id
GUILD_ID=your-test-server-id

Add .env and node_modules to a .gitignore file before your first commit. The project has three files:

discord-mod-bot/
  .env
  commands.js
  deploy-commands.js
  index.js

Step 3: Define the slash commands

commands.js describes each command. discord.js converts the builders to the JSON that Discord expects:

const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');

const commands = [
  new SlashCommandBuilder()
    .setName('ping')
    .setDescription('Check that the bot is online'),

  new SlashCommandBuilder()
    .setName('kick')
    .setDescription('Kick a member from the server')
    .addUserOption((option) =>
      option.setName('user').setDescription('Member to kick').setRequired(true))
    .addStringOption((option) =>
      option.setName('reason').setDescription('Reason for the kick'))
    .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers)
    .setDMPermission(false),
].map((command) => command.toJSON());

module.exports = commands;

setDefaultMemberPermissions hides the command from members who lack the permission. It does not replace the check in your code, which you add in Step 5.

Step 4: Register the commands

Create deploy-commands.js. This script runs once, or whenever you change a command definition:

require('dotenv').config();
const { REST, Routes } = require('discord.js');
const commands = require('./commands');

const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN);

async function deploy() {
  try {
    await rest.put(
      Routes.applicationGuildCommands(process.env.CLIENT_ID, process.env.GUILD_ID),
      { body: commands }
    );
    console.log('Registered ' + commands.length + ' guild commands.');
  } catch (error) {
    console.error('Registration failed:', error.message);
  }
}

deploy();

Guild commands, registered with applicationGuildCommands, update almost at once and are ideal for testing. Global commands, registered with applicationCommands, can take up to an hour to appear, so use them only when the bot is ready for every server.

Step 5: Write the bot and the moderation logic

Create index.js. The token comes from the environment, never from the source code:

require('dotenv').config();
const {
  Client,
  Events,
  GatewayIntentBits,
  PermissionFlagsBits,
} = require('discord.js');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.once(Events.ClientReady, (readyClient) => {
  console.log('Logged in as ' + readyClient.user.tag);
});

client.on(Events.InteractionCreate, async (interaction) => {
  if (!interaction.isChatInputCommand()) return;

  if (interaction.commandName === 'ping') {
    await interaction.reply({ content: 'Pong!', ephemeral: true });
    return;
  }

  if (interaction.commandName === 'kick') {
    if (!interaction.memberPermissions?.has(PermissionFlagsBits.KickMembers)) {
      await interaction.reply({ content: 'You need the Kick Members permission.', ephemeral: true });
      return;
    }

    const member = interaction.options.getMember('user');
    const reason = interaction.options.getString('reason') ?? 'No reason given';

    if (!member) {
      await interaction.reply({ content: 'That user is not on this server.', ephemeral: true });
      return;
    }
    if (!member.kickable) {
      await interaction.reply({ content: 'I cannot kick this member. Check my role position.', ephemeral: true });
      return;
    }

    await member.kick(reason);
    await interaction.reply('Kicked ' + member.user.tag + '. Reason: ' + reason);
  }
});

client.login(process.env.DISCORD_TOKEN);

Two checks protect the command. The permission check stops members without Kick Members, even if they find the command. The kickable check stops the bot when its role is not high enough.

Step 6: Run and test

node deploy-commands.js
node index.js

In your test server, type /ping. You should see "Pong!" visible only to you. Then test /kick with a second test account, not with a real member. Watch the terminal for errors while you test.

Step 7: Keep the bot online

A bot works only while its process runs. Your PC can be used for testing, but a host that stays online is needed for a real server. Options include a small VPS or a managed Node.js host. On a VPS, you can use a process manager:

npm ci --omit=dev
npm install -g pm2
pm2 start index.js --name discord-mod-bot
pm2 logs discord-mod-bot

Set DISCORD_TOKEN, CLIENT_ID and GUILD_ID on the host. Do not upload the .env file to a shared repository.

Common mistakes

  • Using the Client Secret instead of the bot token.
  • Forgetting the applications.commands scope. The commands never appear.
  • Expecting global commands to show up at once. They can take up to an hour.
  • Enabling an intent in code but not in the Developer Portal. Login then fails with a disallowed intents error.
  • Placing the bot role below the target member's role. Discord blocks the kick.
  • Committing .env to a repository.

Using an AI bot maker well

Be specific in your prompt. For example:

Write a Discord bot in JavaScript with Discord.js v14. Add a /ping command and a /kick command with a required user option and an optional reason. Only members with Kick Members can use /kick. Read the token from a .env file. Register the commands with a separate deploy script for one guild.

Check the result for four things: v14 syntax (GatewayIntentBits, not the old Intents.FLAGS), no hardcoded token, a permission check inside the handler, and a deploy script separate from the bot. If you want a ready-to-run project with this structure, the AI Discord bot maker generates it for you. Plans are listed on the pricing page, and the Starter plan is free, with a daily allowance and no card.

Review and test all generated code before you run it on a public server. For large moderation systems, databases, or bots that handle payments or personal data, hire a developer to review the design.

FAQ

Do I need to know JavaScript to use an AI discord bot maker?

Yes, at least the basics. The generator writes the code, but you still install it, read error messages and change settings such as intents and permissions. A short JavaScript course covers what this project needs.

Why don't my slash commands show up in Discord?

Check that the invite included the applications.commands scope, that deploy-commands.js finished without errors, and that you registered guild commands for testing. Restart the Discord client if the list looks stale.

Can the bot stay online without my computer?

Yes, but not on your own PC. Run it on a host that stays online 24/7, such as a VPS or a managed Node.js host.

Ready to build with AI?

Generate your first Minecraft plugin, Discord bot, or FiveM script in 30 seconds. Free to start.

Get Started Free
#Discord#Discord.js#Bot development#Slash commands#Moderation