Compare commits

...

2 commits

Author SHA1 Message Date
e47043317c
Add the ability to reply to images with tdoss command
All checks were successful
CI / CI (push) Successful in 1m28s
2025-04-11 00:02:07 +02:00
4c1199aea5
Only start typing when heavy work begins
Some checks failed
CI / CI (push) Has been cancelled
I found that if I start at the beginning, if the command failed early,
it'd still be typing a couple seconds after replying to your command,
which was kind of annoying.
2025-04-11 00:00:06 +02:00

View file

@ -7,7 +7,6 @@ module.exports = {
name: 'tdoss', name: 'tdoss',
description: 'Combine picture with tdoss album cover template', description: 'Combine picture with tdoss album cover template',
async execute({ message, args }) { async execute({ message, args }) {
message.channel.sendTyping();
let dataDir = path.resolve(__dirname, '..', '..', 'data'); let dataDir = path.resolve(__dirname, '..', '..', 'data');
const directory = path.resolve(dataDir, Math.floor(new Date).toString()) const directory = path.resolve(dataDir, Math.floor(new Date).toString())
@ -20,6 +19,13 @@ module.exports = {
} else if(args[0] && args[0].startsWith("https://") ){ } else if(args[0] && args[0].startsWith("https://") ){
url = args[0]; url = args[0];
}else if(message.reference){
let referencedMessage = await message.fetchReference();
if(referencedMessage.attachments.size > 0)
url = await referencedMessage.attachments.first().url;
else {
message.channel.send("The message you replied to doesn't have any attachments.");
}
} }
else { else {
message.channel.send("You have to provide an image to use this command.\nEither via an attachment or via a link (must be the first argument and start with https://)") message.channel.send("You have to provide an image to use this command.\nEither via an attachment or via a link (must be the first argument and start with https://)")
@ -27,6 +33,7 @@ module.exports = {
return return
} }
// TODO: Download with correct extension. // TODO: Download with correct extension.
message.channel.sendTyping();
const curlCommand = `curl "${url}" -o ${directory}/input.png`; const curlCommand = `curl "${url}" -o ${directory}/input.png`;
if (this.executeCommand(curlCommand).error === true) { if (this.executeCommand(curlCommand).error === true) {