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

325
Views
Discord.js Agregar emojis a un mensaje de envío y obtener la identificación del mensaje

Hola comunidad de Stack Overflow, tengo otra pregunta con respecto a discord.js. Quiero enviar un mensaje y agregarle un emoji, del cual luego quiero obtener la lista de usuarios que han reaccionado. Para hacerlo tengo 2 preguntas:

-¿Cómo puedo agregar un emoji? ¿Necesito un detector de eventos separado para un mensaje o puedo hacerlo dentro de mi evento de interacción Crear? pannel.react("👍") que me da el error: 'TypeError: pannel.react is not a function'. ¿Alguien sabe cómo dejar que esto funcione?

-Mi otra pregunta es si hay alguna forma de acceder a la identificación del mensaje desde el mensaje enviado, para verificar quién participó más tarde en otro comando.

Tengo un archivo de índice con mi comando y controladores de eventos. El script es de mi comando "setup.js" en la carpeta "comandos":

 const { SlashCommandBuilder } = require("@discordjs/builders"); const Discord = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName("setup") .setDescription("Setup Tweet to be rewarded") .addChannelOption(option => option .setName('destination') .setDescription('Select a channel for the reward pannel') .setRequired(true) ) .addStringOption(option => option .setName("twitterlink") .setDescription("Enter the Twitter Link") .setRequired(false) ), async execute(interaction) { interaction.reply({ content: "Pannel send", ephemeral: true }).then( function () { const channel = interaction.options.getChannel("destination"); const channelid = channel.id; const twitterlink = interaction.options.getString("twitterlink"); const pannel = interaction.guild.channels.cache.get(channelid).send(twitterlink); }); } };

Muchas gracias por su ayuda de antemano.

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

0

Bien, con la ayuda de @Gh0st pude encontrar una solución:

El problema para enviar un mensaje es que la función .get() necesita la identificación del canal. Lo he accedido a interaction.options.getChannel("destination").id); . No pude agregar una reacción porque mi comando .send no estaba await: const pannel = await channel.send(twitterlink) . La identificación del mensaje es fácil de encontrar usando .id en la variable del mensaje: const pannelid = pannel.id .

El código resultante se puede encontrar a continuación:

 const { SlashCommandBuilder } = require("@discordjs/builders"); const Discord = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName("setup") .setDescription("Setup Tweet to be rewarded") .addChannelOption(option => option .setName('destination') .setDescription('Select a channel for the reward pannel') .setRequired(true) ) .addStringOption(option => option .setName("twitterlink") .setDescription("Enter the Twitter Link") .setRequired(false) ), async execute(interaction) { // Fixed below here and simplified it const channel = interaction.guild.channels.cache.get(interaction.options.getChannel("destination").id); const twitterlink = interaction.options.getString("twitterlink"); const pannel = await channel.send(twitterlink) pannel.react('🍎'); const pannelid = pannel.id return interaction.reply({ content: "Pannel send", ephemeral: true, }); }, };
about 4 years ago · Juan Pablo Isaza Report

0

Lo limpie un poco y esto debería funcionar para usted

 const { SlashCommandBuilder, } = require("@discordjs/builders"); const Discord = require("discord.js"); module.exports = { data: new SlashCommandBuilder() .setName("setup") .setDescription("Setup Tweet to be rewarded") .addChannelOption(option => option .setName('destination') .setDescription('Select a channel for the reward pannel') .setRequired(true), ) .addStringOption(option => option .setName("twitterlink") .setDescription("Enter the Twitter Link") .setRequired(false), ), async execute(interaction) { // Fixed below here and simplified it const channel = interaction.guild.channels.cache.get(interaction.options.getChannel("destination").id); const twitterlink = interaction.options.getString("twitterlink"); channel.send(twitterlink).then(msg => { msg.react('🍎'), }); return interaction.reply({ content: "Pannel send", ephemeral: true, }); }, };
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!