how to copy photos sent to the specified channel to another channel discord

190
January 19, 2020, at 6:50 PM

hello I already did the code I mentioned. but on the console, on the server, it send the photo into the channel more than once, even 30 times in a row how can i fix this ? also i want embedding this but i think attachments not working on embed. here is my code; edit: i added bulkDelete because if i dont like i said its send million times

client.on("message", msg => {
  if (msg.attachments.size > 0) {
    msg.channel.bulkDelete(1)
const channel1 = msg.guild.channels.find(r => r.name === "önemli-duyuru");
const channel2 = msg.guild.channels.find(r => r.name === "⚠│kural");
const files = [channel1.lastMessage.attachments.first()].map(attachment => attachment.proxyURL);
channel2.send(`Bu Fotoğraf ${msg.author} Tarafından Gönderildi.`, {files});
    console.log(files)
  }
  });
Answer 1

When receiving the message, make sure to check whether your bot is the message author, otherwise you'll get stuck in a potentially endless loop:

if (msg.author.id === client.user.id) return

message events are emitted for every message, including the ones sent by the bot.

READ ALSO
Express.js routing: how to prevent reloading of previous page?

Express.js routing: how to prevent reloading of previous page?

I am new to express (or web development in general) and have a question about routingI am creating a web app on Firebase with pure JS, and am using routing on Firebase cloud functions

164
Populate is not a function

Populate is not a function

Why i get this error and how it should be?

231
How to use split function in node js

How to use split function in node js

I have combined two strings at the client side to publish on a topic

162