tdoss: Pull the latest image in chat if none are provided
All checks were successful
CI / CI (push) Successful in 1m27s

limited to 20 last messages for now
This commit is contained in:
SileNce5k 2025-04-12 03:20:18 +02:00
parent 7dc9be5598
commit 6f8dd7ebf6
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -32,9 +32,15 @@ module.exports = {
} }
} }
else { else {
message.channel.send("You have to provide an image to use this command.\nEither through an attachment, a link, or you can reply to a message with an image attachment.") let lastMessages = await message.channel.messages.fetch({limit: 20, cache: false});
fs.rmSync(`${directory}`, {recursive: true}) let lastMessageWithAttachment = lastMessages.find(m => m.attachments.size > 0);
return if(!lastMessageWithAttachment){
message.channel.send("Couldn't find an image to use this command on.")
fs.rmSync(`${directory}`, {recursive: true})
return
}
url = lastMessageWithAttachment.attachments.first().url;
} }
// TODO: Download with correct extension. // TODO: Download with correct extension.
message.channel.sendTyping(); message.channel.sendTyping();