From 2117628d4ea7cfecb1ae19ba4ca7d8ebdf028079 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 16 Jan 2025 21:27:45 -0700 Subject: [PATCH] Add check for folder exists --- messageHandlers/create_prod.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/messageHandlers/create_prod.js b/messageHandlers/create_prod.js index f37d037..aaa1fe5 100644 --- a/messageHandlers/create_prod.js +++ b/messageHandlers/create_prod.js @@ -100,6 +100,9 @@ const execute = async (message) => { } const file = fs.createWriteStream(`./productFiles/${crypto.randomBytes(8).toString('hex')}`); const prodId = crypto.randomUUID(); + if (!fs.existsSync('./productFiles')) { + fs.mkdirSync('./productFiles'); + } download(attachment.url, file.path, (err) => { if (err) { message.channel.send('Failed to download the file.');