Message Attachment

Hello, how can I send file attachments? I have the following code:
const attachment = new Attachment(
path.join(
__dirname,
"../",
"reports",
`ticket-${row.id}.html.rename`
)
);

await interaction.channel.send(
`Ticket #${row.id} closed by ${interaction.user.username}`,
{
files: [attachment],
}
);
const attachment = new Attachment(
path.join(
__dirname,
"../",
"reports",
`ticket-${row.id}.html.rename`
)
);

await interaction.channel.send(
`Ticket #${row.id} closed by ${interaction.user.username}`,
{
files: [attachment],
}
);
and get the following error:
TypeError: Cannot use 'in' operator to search for 'size' in
TypeError: Cannot use 'in' operator to search for 'size' in
3 Replies
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
Squid
Squid16mo ago
You should be using AttachmentBuilder for sending your own attachments instead of Attachment which is a class used internally for what you receive
Nlmyr
Nlmyr16mo ago
oh ok If I use this it send the message without attachment
const attachmentBuilder = new AttachmentBuilder(path.join(
__dirname,
"../",
"reports",
`ticket-${row.id}.html.rename`
));

await interaction.channel.send(
`Ticket #${row.id} closed by ${interaction.user.username}`,
{
files: [attachmentBuilder],
}
);
const attachmentBuilder = new AttachmentBuilder(path.join(
__dirname,
"../",
"reports",
`ticket-${row.id}.html.rename`
));

await interaction.channel.send(
`Ticket #${row.id} closed by ${interaction.user.username}`,
{
files: [attachmentBuilder],
}
);
i have fixed it missed content