diff --git a/messageHandlers/update_prod.js b/messageHandlers/update_prod.js index 489e715..07b6656 100644 --- a/messageHandlers/update_prod.js +++ b/messageHandlers/update_prod.js @@ -97,6 +97,7 @@ const execute = async (message) => { cancel(message.author); return; } + const productId = global.productUpdateData[message.author.id].id; const file = fs.createWriteStream(`./productFiles/${crypto.randomBytes(8).toString('hex')}`); download(attachment.url, file.path, async (err) => { if (err) { @@ -105,7 +106,7 @@ const execute = async (message) => { return; } const fileType = attachment.name.split('.').pop(); - await pool.query('UPDATE products SET file = ?, fileType = ? WHERE id = ?', [file.path.split('/').pop(), fileType, global.productUpdateData[message.author.id].id]); + await pool.query('UPDATE products SET file = ?, fileType = ? WHERE id = ?', [file.path.split('/').pop(), fileType, productId]); message.channel.send('File updated successfully!'); }); } else {