tdoss: Pull the latest image in chat if none are provided
All checks were successful
CI / CI (push) Successful in 1m27s
All checks were successful
CI / CI (push) Successful in 1m27s
limited to 20 last messages for now
This commit is contained in:
parent
7dc9be5598
commit
6f8dd7ebf6
1 changed files with 9 additions and 3 deletions
|
@ -32,10 +32,16 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
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});
|
||||
let lastMessageWithAttachment = lastMessages.find(m => m.attachments.size > 0);
|
||||
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.
|
||||
message.channel.sendTyping();
|
||||
if(await this.downloadImage(url, path.resolve(directory, "input.png")) != 0){
|
||||
|
|
Loading…
Add table
Reference in a new issue