Add check for folder exists

This commit is contained in:
Christopher Cookman 2025-01-16 21:27:45 -07:00
parent 1e10421249
commit 2117628d4e

View file

@ -100,6 +100,9 @@ const execute = async (message) => {
} }
const file = fs.createWriteStream(`./productFiles/${crypto.randomBytes(8).toString('hex')}`); const file = fs.createWriteStream(`./productFiles/${crypto.randomBytes(8).toString('hex')}`);
const prodId = crypto.randomUUID(); const prodId = crypto.randomUUID();
if (!fs.existsSync('./productFiles')) {
fs.mkdirSync('./productFiles');
}
download(attachment.url, file.path, (err) => { download(attachment.url, file.path, (err) => {
if (err) { if (err) {
message.channel.send('Failed to download the file.'); message.channel.send('Failed to download the file.');