Me gustaría transferir un mensaje incrustado a otro chat con reacciones, pero tengo algunos problemas porque el BOT no transfiere el mensaje con este código:
client.on("messageCreate", message => { if (message.channel.id === analiseChannelID) { message.react(aprovada); message.react(nula); message.react(negada); } else if (message.channel.id === aprovadasChannelID) { message.react(arquivada); message.react(negada); } else if (message.channel.id === negadasChannelID) { message.react(arquivada); message.react(negada); } else if (message.channel.id === nulaChannelID) { message.react(arquivada); message.react(negada); } }); client.on("messageReactionAdd", ({ message }) => { const analiseChannel = message.client.channels.cache.get(analiseChannelID); const aprovadasChannel = message.client.channels.cache.get(aprovadasChannelID); console.log("Reaction"); if (message.author.bot) return; if (message.guild.channels.id = analiseChannelID) { const { embeds } = message aprovadasChannel.send({ embeds }) } });Cuando agregué esto para no dejarlo tomar su propia reacción y enviar spam al chat:
if (message.author.bot) return;simplemente ignora para transferir el mensaje.
Lo que tengo que hacer es que si hay una nueva inserción en
analiseChannelID, debería reaccionar con 3 emojis y, dependiendo de esas reacciones, transferiría el mensaje aaprovadasChannelIDy lo eliminaría deanaliseChannelID
Como se dijo en los comentarios , enviaste el mensaje como un webhook de Discord. Los webhooks se clasifican como mensajes de bot. Si estaba tratando de obtener al usuario que reaccionó, puede usar el segundo argumento del evento messageReactionAdd . Es un objeto User que representa al usuario que reaccionó.
client.on("messageReactionAdd", ({ message }, user) => { //get the User who reacted const analiseChannel = message.client.channels.cache.get(analiseChannelID); const aprovadasChannel = message.client.channels.cache.get(aprovadasChannelID); console.log("Reaction"); if (user.bot) return; if (message.guild.channels.id = analiseChannelID) { const { embeds } = message aprovadasChannel.send({ embeds }) } });Tenga en cuenta que hay más errores en el código.
== o ===message.guild.channels.id no está definido. Si desea verificar si existe un canal, que es lo que creo que está haciendo, use message.guild.channels.cache.has("ID")Supongo que el problema está aquí:
if (message.guild.channels.id = analiseChannelID) Lo que está haciendo al usar el operador único '=' es asignar el valor analiseChannelID a message.guild.channels.id (que ni siquiera existe ya que guild.channels es un administrador de canales) y luego verificar si el valor asignado es no es un valor falso para javascript. Desafortunadamente, su pregunta no es muy clara sobre lo que está tratando de lograr, pero supongo que lo que quiere hacer es algo como:
client.on("messageReactionAdd", ({ message }) => { if (message.author.bot) return; const analiseChannel = message.client.channels.resolve(analiseChannelID); const aprovadasChannel = message.client.channels.resolve(aprovadasChannelID); // you can use the has method since the cache is a Collection instance // this if you want to check if the guild has a channel with that id if (message.guild.channels.cache.has(analiseChannelID)) { const { embeds } = message; aprovadasChannel.send({ embeds }); } // this if you want to ckeck if the channel in which the message has been sent is that channel id if(message.channel.id === analiseChannelID) { /* do stuff */ } });