Start Bot

Start your first bot

1. Import startBot

First, make sure to import the startBot function from the mvk-project package:

const { startBot } = require('mvk-project');

2. Create a Bot Client

Next, create a client instance by calling the startBot function with your configuration. Begin by providing your bot's token:

const client = startBot({
  token: '...', // Replace with your bot's token
});

3. Add Intents

Specify the intents that your bot needs. Intents are necessary to receive certain types of events from the Discord API. You can add more intents if needed:

const client = startBot({
  token: '...', // Replace with your bot's token
  intents: [
    'Guilds',
    'GuildMessages',
    'MessageContent'
    // Add more intents if needed
  ]
});

4. Set a Command Prefix

Set a prefix for your bot's commands. This prefix will be used to identify commands sent to your bot:

const client = startBot({
  token: '...', // Replace with your bot's token
  intents: [
    'Guilds',
    'GuildMessages',
    'MessageContent'
    // Add more intents if needed
  ],
  prefix: '!', // Command prefix for your bot
});

5. (Optional) Add a Startup Message

Optionally, you can add a log message to be displayed in the console when your bot starts:

const client = startBot({
  token: '...', // Replace with your bot's token
  intents: [
    'Guilds',
    'GuildMessages',
    'MessageContent'
    // Add more intents if needed
  ],
  prefix: '!', // Command prefix for your bot
  consoleLog: 'MVK Project is online' // Log message when the bot starts
});

Final Code

Here is the complete setup code:

const { startBot } = require('mvk-project');

const client = startBot({
  token: '...', // Replace with your bot's token
  intents: [
    'Guilds',
    'GuildMessages',
    'MessageContent'
    // Add more intents if needed
  ],
  prefix: '!', // Command prefix for your bot
  consoleLog: '${bot.username} is online' // Log message when the bot starts
});

If everything is set up correctly, you should see a startup message in your console like:

MVK Project is online

Last updated