Open ELONISEVIL opened 1 month ago
node -v npm -v
This should display the versions of Node.js and npm installed.
Create a New Application:
Get Your Bot Token:
Create a New Directory and Navigate to It:
mkdir my-discord-bot cd my-discord-bot
Initialize a New Node.js Project:
npm init -y
Install Discord.js Library:
npm install discord.js
Create a New File named bot.js:
bot.js
const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] }); const token = 'YOUR_BOT_TOKEN_HERE'; // Replace with your bot's token client.once('ready', () => { console.log('Bot is online!'); }); client.on('messageCreate', (message) => { if (message.content === '!ping') { message.channel.send('Pong!'); } }); client.login(token);
Run the Bot:
node bot.js
You should see the message "Bot is online!" in your terminal, indicating that your bot is running.
Step 2: Create a Discord Bot
Create a New Application:
Get Your Bot Token:
Step 3: Set Up Your Project
Create a New Directory and Navigate to It:
Initialize a New Node.js Project:
Install Discord.js Library:
Step 4: Create Your Bot's Code
Create a New File named
bot.js
:Step 5: Run Your Bot
Run the Bot:
You should see the message "Bot is online!" in your terminal, indicating that your bot is running.
Step 6: Invite Your Bot to Your Server