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

288
Views
DiscordAPIError, mi Discordbot no puede incrustarse

Estoy tratando de programar un bot de chat de discord, que cuando el comando '! ayuda' se dirige a un determinado canal de texto, el bot escribe un mensaje directo a la persona que escribió el comando para responder una serie de preguntas, este es el código que intento:

 const {Client, RichEmbed, Intents, MessageEmbed} = require('discord.js'); const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES] }); const token = 'TOKEN'; const PREFIX = '!'; bot.on('ready', () => { console.log(`Logged in as ${bot.user.tag}!`); }) bot.on('messageCreate', message => { let args = message.content.substring(PREFIX.length).split(" "); switch (args[0]) { case 'help': const Embed = new MessageEmbed() .setTitle("Helper Embed") .setColor(0xFF0000) .setDescription("Make sure to use the !help to get access to the commands"); message.author.send(Embed); break; } }); bot.login(token);

Sin embargo, me arroja un error de DiscordAPIError. Cual es la siguiente:

 node_modules/discord.js/src/rest/RequestHandler.js:350 throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: Cannot send an empty message at RequestHandler.execute (/Users/mybot/node_modules/discord.js/src/rest/RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (/Users/mybot/node_modules/discord.js/src/rest/RequestHandler.js:51:14) at async DMChannel.send (/Users/mybot/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:176:15) { method: 'post', path: '/channels/98595393932745/messages', code: 50006, httpStatus: 400, requestData: { json: { content: undefined, tts: false, nonce: undefined, embeds: undefined, components: undefined, username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: undefined, attachments: undefined, sticker_ids: undefined }, files: [] } }
about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

Si estoy en lo correcto y está usando discord.js v13, debe usar message.author.send({embeds: [Embed]}) para enviar incrustaciones.

about 4 years ago · Santiago Gelvez Report

0

En discord.js v13, ya no envía mensajes directamente, debe especificar si es una inserción, componentes, etc. aquí hay un ejemplo

 message.author.send({content: 'you need help'}) // Normal message message.author.send({embeds: [Embed]}) // embedded message message.author.send({content: 'you need help', embeds: [Embed], components: [buttonRow]}) // To send message, embed and components

Para hacer que una respuesta de interacción sea efímera, usa el mismo método, pero booleano:

 interaction.reply({embeds: [Embed], components: [row], ephemeral: true})
about 4 years ago · Santiago Gelvez 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!