const Discord = require('discord.js'); // fs const fs = require('fs'); // path const path = require('path'); // config const config = require('./config.json'); // config.json const token = config.token; // config config.json const PREFIX = config.prefix; const { Client, Intents } = require('discord.js'); const client = new Client({ intents: \[Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES\] }) client.commands = new Discord.Collection(); // message client.on('message', message =\> { // message not sent by bot if (!message.author.bot) { // if the message starts with the prefix if (message.content.startsWith(PREFIX)) { // split the message into an array const args = message.content.slice(PREFIX.length).split(/ +/); // command is the first element of the array const command = args.shift().toLowerCase(); // ping command if (command === 'ping') { // send a message to the channel message.channel.send('pong'); } // success message after login client.on('ready', () =\> { console.log(`Logged in as ${client.user.tag}!`); }) // token config file client.login(config.token);así que ejecuto el nodo index.js, se supone que debe mostrarse como "mi nombre de bot aquí" en la terminal VSC y debería estar en línea en la discordia, pero no es así y no puedo resolverlo.
El formateo te salvará la vida, Bro: Además, recomendaría menos comentarios. Es mucho ruido. Refactoricé estas cosas. Mira cuánto mejor se ve tu código:
const { token, prefix: PREFIX } = require('./config.json'); const { Collection, Client, Intents } = require('discord.js'); const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] }) client.commands = new Collection(); client.on('message', message => { if (message.author.bot) return if (!message.content.startsWith(PREFIX)) return const args = message.content.slice(PREFIX.length).split(' '); const command = args.shift().toLowerCase(); if (command === 'ping') { message.channel.send('pong'); } }) client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }) client.login(token);