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

152
Views
No puedo acceder al cliente en mi archivo de comando discord.js

Mi archivo de rol de reacción:

 module.exports = { name: "rr", desc: "make a reaction role --> <", async run(message, client) { const jsEmoji = "🍏"; const pythonEmoji = "🍍"; let embedMessage = await message.channel.send("react for a role"); embedMessage.react(jsEmoji); embedMessage.react(pythonEmoji); client.on("messageReactionAdd", (user, reaction) => { console.log("he reacted"); }); }, };

mi archivo bot:

 const intents = new Discord.Intents(32767);

Inicialicé mi cliente aquí

 const client = new Discord.Client({ intents: intents }); const fs = require("fs"); const commandFolders = fs.readdirSync("./Commands"); client.commands = new Discord.Collection(); commandFolders.forEach((folder) => { const commandFiles = fs .readdirSync(`./Commands/${folder}`) .filter((file) => file.endsWith(".js")); commandFiles.forEach((file) => { const command = require(`./Commands/${folder}/${file}`); client.commands.set(command.name, command); }); }); client.on("messageCreate", (message) => { if (message.author.bot || !message.content.startsWith(config.prefix)) return; const [command, ...args] = message.content .substring(config.prefix.length) .split(/\s+/);

Intenté obtener acceso al cliente aquí y pasarlo a la función de ejecución, pero eso no funcionó.

 client.commands.forEach((cmd) => command === cmd.name ? client.commands.get(cmd.name).run(message, args, client) : null ); }); client.login(config.token);

Mi error:

 client.on("messageReactionAdd", (user, reaction) => { ^ TypeError: client.on is not a function

¿Existe otra forma de acceder a mi cliente?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

sus argumentos son incorrectos en el archivo de comando .

Debe usar async run(client, message, args)

Aquí hay un código completo para usted:

 module.exports = { name: "rr", desc: "make a reaction role --> <", async run(client, message, args) { const jsEmoji = "🍏"; const pythonEmoji = "🍍"; let embedMessage = await message.channel.send("react for a role"); embedMessage.react(jsEmoji); embedMessage.react(pythonEmoji); client.on("messageReactionAdd", (user, reaction) => { console.log("he reacted"); }); }, };
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!