Can bot somehow copy the url of the message he just send? I was trying to do something like that but it didnt work
channel1.send("test",{
embed:embed,
});
const messageurl = client.message.cache.find(URL)
message.channel.send(`${messageurl}`)
First, the options for sending message in a channel is a string or an object. If you use that wrong method, your bot only sends test into the text channel. Replace it with .send({ <options> }) so you can send multiple items.
Second, embed option for sending a message must be an array if you are using discord.js v13:
channel.send({ embeds: [] });
Finally, <textChannel>.send() method returns a Promise with message sent. Get the message your bot sent by defining const msg = await channel1.send({ <options> });(Await is only available in async function). Now we can access the message's attribute such as ID, url, author… etc. The URL which you want is the msg.url.
Here is the final code:
(async () => {
const msg = await channel1.send({
content: "test",
embeds: [ embed ],
});
channel1.send(`${msg.url}`);
})();
Hope this will help you, comment on this answer if you still have any issue about it.
Use this :
const msg = await channel1.send("test",{
embed:embed,
});
channel1.send(`${msg.url}`)
channel1.send({ content: `${msg.url}`, embeds: [embed] })