This commit is contained in:
Christopher Cookman 2025-01-16 21:45:56 -07:00
parent 2117628d4e
commit a17de17aeb

View file

@ -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,19 +112,12 @@ 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.');
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.');
}