const { Client, GatewayIntentBits } = require('discord.js');

// Creamos la instancia del cliente con los permisos (intents) necesarios
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.DirectMessages,
    ]
});

client.once('clientReady', () => {
    console.log(`✅ Bot conectado como: ${client.user.tag}`);
});

client.on('messageCreate', (message) => {
    
    // Evita que el bot se responda a sí mismo
    if (message.author.bot) return;

    if (message.content === 'ping') {
        console.log('hay un ping');
        message.reply('¡Pong! 🏓');
    }
});

// Reemplaza 'TU_TOKEN_AQUÍ' con el token de la pestaña "Bot" del Developer Portal
client.login('XXXX');

in XXXX paste your token


create a server discord

the discord server:

A Discord server is for you and your friends to connect and talk via text or voice.


create discord application (You must do this before obtaining your application’s bot token)

https://discord.com/developers/applications

“crear” button: