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

376
Views
Estoy tratando de hacer un bot de música discord, pero cada vez que ejecuto el código recibo un mensaje de error no definido

Soy bastante nuevo en js y quería hacer un bot de discordia musical. Este código funcionaba hace aproximadamente una hora sin un sistema de cola, así que intenté agregar uno. El código se rompió, así que eliminé los cambios que hice y el error aún persistía. Sigo recibiendo "ReferenceError: el mensaje no está definido". ¿Alguien sabe cuál es el problema?

 const Discord = require('discord.js'); const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]}); const config = require('./config.json'); client.music = require("discord.js-musicbot-addon"); var queue= new Array(); client.on("message", (msg) => { if (msg.author.bot) return; const client = msg.client; // Get the command from the message. const command = message.substring(musicbot.botPrefix.length).split(/[ \n]/)[0].trim(); // Get the suffix, the String after the command. const suffix = message.substring(musicbot.botPrefix.length + command.length).trim(); let prefix = "<3" if (msg.content.startsWith(prefix) && command == "play") { // pass the Message Object (msg) and the suffix. queue.push(msg) for(var i=0; i <= queue.length; queue.length--){ client.music.bot.playFunction(queue[0], suffix); } queue.splice(0,1); }; });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

en la función client.on está utilizando el objeto de mensaje, pero ha nombrado el objeto msg . Creo que tienes que cambiar eso. Entonces se verá así:

 const Discord = require('discord.js'); const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]}); const config = require('./config.json'); client.music = require("discord.js-musicbot-addon"); var queue= new Array(); client.on("message", (msg) => { if (msg.author.bot) return; const client = msg.client; // Get the command from the message. const command = msg.substring(musicbot.botPrefix.length).split(/[ \n]/)[0].trim(); // Get the suffix, the String after the command. const suffix = msg.substring(musicbot.botPrefix.length + command.length).trim(); let prefix = "<3" if (msg.content.startsWith(prefix) && command == "play") { // pass the Message Object (msg) and the suffix. queue.push(msg) for(var i=0; i <= queue.length; queue.length--){ client.music.bot.playFunction(queue[0], suffix); } queue.splice(0,1); }; });

Lo que cambió es que los 2 objetos de message se renombraron a msg

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!