Add check for folder exists
This commit is contained in:
parent
1e10421249
commit
2117628d4e
|
@ -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.');
|
||||||
|
|
Loading…
Reference in a new issue