Use a tdoss directory in the data directory

This is better because then I won't have a bunch of directories with
random numbers directly in the data/ directory.
Which makes it easier to clean up whenever something fails and the
cleanup isn't done.
This commit is contained in:
SileNce5k 2025-05-10 15:04:57 +02:00
parent c3f7abce5d
commit 8570b2a204
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -10,9 +10,10 @@ module.exports = {
description: 'Combine picture with tdoss album cover template', description: 'Combine picture with tdoss album cover template',
async execute({ message, args }) { async execute({ message, args }) {
let dataDir = path.resolve(__dirname, '..', '..', 'data'); let tdossDir = path.resolve(process.cwd, 'data', 'tdoss');
const directory = path.resolve(dataDir, Math.floor(new Date).toString())
fs.mkdirSync(directory) const directory = path.resolve(tdossDir, Math.floor(new Date).toString())
fs.mkdirSync(directory, {recursive: true})
let url = ""; let url = "";
if(message.attachments.size > 0){ if(message.attachments.size > 0){
@ -58,7 +59,7 @@ module.exports = {
} }
const command = `magick ${dataDir}/tdoss_template.png \\( ${directory}/input.png -resize 800x800^ -gravity center -extent 1000x1000 \\) -compose dst-over -composite ${directory}/tdoss_result.png`; const command = `magick ${tdossDir}/tdoss_template.png \\( ${directory}/input.png -resize 800x800^ -gravity center -extent 1000x1000 \\) -compose dst-over -composite ${directory}/tdoss_result.png`;
if (this.executeCommand(command).error === true) { if (this.executeCommand(command).error === true) {
message.channel.send("Something went wrong during image manipulation.\nTry again and if it keeps happening, contact the owner of the bot.") message.channel.send("Something went wrong during image manipulation.\nTry again and if it keeps happening, contact the owner of the bot.")
fs.rmSync(`${directory}`, {recursive: true}) fs.rmSync(`${directory}`, {recursive: true})