Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
El bot Discord.JS no responde a los comandos ni devuelve un error en la consola al respecto

He estado luchando para que funcione el controlador de comandos de mi nuevo bot Discord, mientras ve los archivos de comandos (como lo indica su entrada de registro al inicio que indica la cantidad de comandos que ha cargado) no está enviando los mensajes, o ni siquiera los está ejecutando.

Aquí está mi código:

 const { Client, Intents, Collection } = require('discord.js'); const { token, ownerid, statuses, embedColors, prefix } = require('./cfg/config.json'); const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); const fs = require('fs'); const { config } = require('process'); client.commands = new Collection(); const commands = []; const cmdfiles = fs.readdirSync('./cmds').filter(file => file.endsWith('.js')); client.once('ready', () => { console.clear console.log(`Ready to go, Found ${cmdfiles.length} commands and ${statuses.length} statuses!`) setInterval(() => { var status = Math.floor(Math.random() * (statuses.length -1) +1) client.user.setActivity(statuses[status]); }, 20000) }), client.on("error", (e) => console.log(error(e))); client.on("warn", (e) => console.log(warn(e))); // Command Handler for (const file of cmdfiles) { const command = require(`./cmds/${file}`); commands.push(command.data); } client.on('messageCreate', message => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).trim().split(/ +/); const command = args.shift().toLowerCase(); if (!client.commands.has(command)) { embeds: [{ title: ":x: Oopsie!", color: config.embedColors.red, description: `Command ${args.[0]} doesn't exist! Run ${config.prefix}help to see the avaliable commands!`, footer: app.config.footer + " Something went wrong! :(" }]; } else { try { client.commands.get(command).execute(message, args); } catch (error) { console.error(error); embeds: [{ title: ":x: Oopsie!", description: "Command execution failed", fields: [ { name: "Error Message", value: `${e.message}` } ], footer: app.config.footer + " Something went wrong :(" }]; } message.channel.send }}); client.login(token);

y el comando de prueba es

 module.exports = { name: "test", description: "does as it implies, dingusA", async execute(client, message, args) { message.channel.send("This is a message!"); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Necesitas la intención GUILD_MESSAGES para recibir mensajes en los gremios.
Agregue la siguiente intención en su código

 const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] })

Esto se aplica a otras cosas también, por ejemplo. DIRECT_MESSAGES para DM y etc.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!