diff --git a/messageHandlers/update_prod.js b/messageHandlers/update_prod.js index cc4b7c0..96b5fd7 100644 --- a/messageHandlers/update_prod.js +++ b/messageHandlers/update_prod.js @@ -35,7 +35,8 @@ const cancel = (user) => { } const execute = async (message) => { - switch (global.productUpdateData[message.author.id].type) { + const userData = global.productUpdateData[message.author.id]; + switch (userData?.type) { case "name": // Name const newName = message.content.trim(); if (newName.toLowerCase() === 'cancel') { @@ -142,15 +143,15 @@ const execute = async (message) => { return; } // Proceed with deletion + const pid = userData.id; message.channel.send('Deletion Confirmed. Starting deletion process...').then(async msg => { - let pid = global.productUpdateData[message.author.id].id; let curMsg = msg.content; // Delete fileAuth - curMsg = curMsg + '\nDeleting file authorizations...' + curMsg = curMsg + '\nDeleting file authorizations...'; await msg.edit(curMsg); await pool.query('DELETE FROM fileAuth WHERE product = ?', [pid]); // Delete file - curMsg = curMsg + '\nDeleting product file...' + curMsg = curMsg + '\nDeleting product file...'; await msg.edit(curMsg); const [product] = await pool.query('SELECT file FROM products WHERE id = ?', [pid]); if (product) { @@ -185,4 +186,4 @@ const execute = async (message) => { delete global.productUpdateData[message.author.id]; delete global.dmHandlers[message.author.id]; } - module.exports = execute \ No newline at end of file +module.exports = execute \ No newline at end of file