I would like to be able to delete an image sent automatically. But ONLY the pictures and not all the attachments.
I'm currently using message.attachments.size > 0
. But I know that removes all attachments; what I don't want!
async execute(message, client) {
if (!message.guild || message.author.bot) return;
if (message.channel.id === 'CHANNEL-ID' && message.attachments.size > 0) {
message.delete()
}
With my research, I came across a post explaining that it was enough to add filters; message.attachments.find(attachment => attachment.filename.endsWith('png') || attachment.filename.endsWith('jpg') || attachment.filename.endsWith('gif'))
But for me it does not work; shows me an error, it does not seem to recognize the .endsWith
node version: 16.13.2 | npm version: 8.1.2
Thanks in advance !