Image in Embed

const { EmbedBuilder } = require('discord.js');
const { twiter } = require('../config.json');

module.exports = {
name: 'messageCreate',
async execute(message) {
const targetChannelId = twiter;

if (message.channel.id === targetChannelId && !message.author.bot) {
try {
const messageContent = message.content;

await message.delete();

const creationTimestamp = Math.floor(message.createdTimestamp / 1000);

const embed = new EmbedBuilder()
.setColor('#1DA1F2')
.setTitle(':bird: | Twitter')
.setDescription(
`**Użytkownik:** __<@${message.author.id}>__ wysłał nową wiadomość 🔔\n\n` +
`**Treść:** ${messageContent || 'Brak treści'}\n\n` +
`**Załącznik:** ${message.attachments.size > 0 ? message.attachments.first().url : 'Brak załączników'}`
)
.setFooter({ text: `LublinRP | Twitter` })
.setTimestamp();

await message.channel.send({ embeds: [embed] });

} catch (error) {
console.error('Błąd podczas przetwarzania wiadomości:', error);
}
}
},
};
const { EmbedBuilder } = require('discord.js');
const { twiter } = require('../config.json');

module.exports = {
name: 'messageCreate',
async execute(message) {
const targetChannelId = twiter;

if (message.channel.id === targetChannelId && !message.author.bot) {
try {
const messageContent = message.content;

await message.delete();

const creationTimestamp = Math.floor(message.createdTimestamp / 1000);

const embed = new EmbedBuilder()
.setColor('#1DA1F2')
.setTitle(':bird: | Twitter')
.setDescription(
`**Użytkownik:** __<@${message.author.id}>__ wysłał nową wiadomość 🔔\n\n` +
`**Treść:** ${messageContent || 'Brak treści'}\n\n` +
`**Załącznik:** ${message.attachments.size > 0 ? message.attachments.first().url : 'Brak załączników'}`
)
.setFooter({ text: `LublinRP | Twitter` })
.setTimestamp();

await message.channel.send({ embeds: [embed] });

} catch (error) {
console.error('Błąd podczas przetwarzania wiadomości:', error);
}
}
},
};
I have trouble to image. The code is when person sent something in channel the bot delete it and send embed, (and when person add image the bot will showup in the embed) <- there is the issiue, the bot is sending like image.png not the photo
7 Replies
d.js toolkit
d.js toolkit3d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Eryczus
EryczusOP3d ago
this is how its work today
No description
Eryczus
EryczusOP3d ago
And this is how its should work
No description
NyR
NyR3d ago
Well your putting it inside the description, so it shows the link
d.js docs (dev)
:method: EmbedBuilder#setImage() [email protected] Sets the image of this embed.
NyR
NyR3d ago
Set it as an image to the embed ^
Инот
Инот8h ago
You need to make attachment before the message will be deleted. Just make an attachment by new AttachmentBuilder(message.attachments.first().url), and add it to message like file. Then use it in embed by attachment://image.(here attachment type). This is done because when a message is deleted, Discord also deletes its contents from its servers, be it files or pictures, so we duplicate them temporarily into RAM, and then, under the guise of a new attachment, we send them together to the embed
Want results from more Discord servers?
Add your server