This commit is contained in:
Christopher Cookman 2025-09-15 11:06:10 -06:00
parent 048dbef11f
commit 7808c815fe

View file

@ -38,10 +38,10 @@ const execute = async (interaction) => {
const [existingProduct] = await pool.query('SELECT * FROM products WHERE devProductId = ? AND hubId = ?', [prod.devproduct_id, hub.id]);
if (!existingProduct) continue; // No matching product, skip
// Product exists, check if theres already a purchase record
const [existingPurchase] = await pool.query('SELECT * FROM purchases WHERE userId = ? AND productId = ?', [user.id, existingProduct.id]);
const [existingPurchase] = await pool.query('SELECT * FROM purchases WHERE robloxId = ? AND productId = ?', [user.robloxId, existingProduct.id]);
if (existingPurchase) continue; // Already have a purchase record, skip
// Create purchase record
await pool.query('INSERT INTO purchases (userId, productId, hubId) VALUES (?, ?, ?)', [user.id, existingProduct.id, hub.id]);
await pool.query('INSERT INTO purchases (robloxId, productId, hubId) VALUES (?, ?, ?)', [user.robloxId, existingProduct.id, hub.id]);
console.log(`Imported purchase of product ${prod.name} > ${existingProduct.name} for user ${user.robloxId}`);
count++;
}