From a17de17aeb72188bfa2c24b407128d51947caf2e Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 16 Jan 2025 21:45:56 -0700 Subject: [PATCH] aaa --- messageHandlers/create_prod.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/messageHandlers/create_prod.js b/messageHandlers/create_prod.js index aaa1fe5..658c0d3 100644 --- a/messageHandlers/create_prod.js +++ b/messageHandlers/create_prod.js @@ -103,7 +103,7 @@ const execute = async (message) => { if (!fs.existsSync('./productFiles')) { fs.mkdirSync('./productFiles'); } - download(attachment.url, file.path, (err) => { + download(attachment.url, file.path, async (err) => { if (err) { message.channel.send('Failed to download the file.'); cancel(message.author); @@ -112,18 +112,11 @@ const execute = async (message) => { global.productCreationData[message.author.id].filePath = file.path.split('/').pop(); let fileType = attachment.name.split('.').pop(); global.productCreationData[message.author.id].step = 5; - message.channel.send('File uploaded successfully. Product creation complete.'); - pool.query(`INSERT INTO products (id, name, description, devProductId, decalId, file, fileType, hubId) VALUES (?, ?, ?, ?, ?, ?, ?, ?);`, [prodId, global.productCreationData[message.author.id].name, global.productCreationData[message.author.id].description, global.productCreationData[message.author.id].devProductId, global.productCreationData[message.author.id].imageId, global.productCreationData[message.author.id].filePath, fileType, global.productCreationData[message.author.id].hub], (err) => { - if (err) { - console.error(err); - message.channel.send('An error occurred while creating the product.'); - cancel(message.author); - return; - } - message.author.send('Product created successfully.'); - delete global.productCreationData[message.author.id]; - delete global.dmHandlers[message.author.id]; - }); + await message.channel.send('File uploaded successfully. Product creation complete.'); + await pool.query(`INSERT INTO products (id, name, description, devProductId, decalId, file, fileType, hubId) VALUES (?, ?, ?, ?, ?, ?, ?, ?);`, [prodId, global.productCreationData[message.author.id].name, global.productCreationData[message.author.id].description, global.productCreationData[message.author.id].devProductId, global.productCreationData[message.author.id].imageId, global.productCreationData[message.author.id].filePath, fileType, global.productCreationData[message.author.id].hub]); + await message.author.send('Product created successfully.'); + delete global.productCreationData[message.author.id]; + delete global.dmHandlers[message.author.id]; }); } else { message.channel.send('No file attached. Please upload the product file.');