aaa
This commit is contained in:
parent
2117628d4e
commit
a17de17aeb
|
@ -103,7 +103,7 @@ const execute = async (message) => {
|
||||||
if (!fs.existsSync('./productFiles')) {
|
if (!fs.existsSync('./productFiles')) {
|
||||||
fs.mkdirSync('./productFiles');
|
fs.mkdirSync('./productFiles');
|
||||||
}
|
}
|
||||||
download(attachment.url, file.path, (err) => {
|
download(attachment.url, file.path, async (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
message.channel.send('Failed to download the file.');
|
message.channel.send('Failed to download the file.');
|
||||||
cancel(message.author);
|
cancel(message.author);
|
||||||
|
@ -112,18 +112,11 @@ const execute = async (message) => {
|
||||||
global.productCreationData[message.author.id].filePath = file.path.split('/').pop();
|
global.productCreationData[message.author.id].filePath = file.path.split('/').pop();
|
||||||
let fileType = attachment.name.split('.').pop();
|
let fileType = attachment.name.split('.').pop();
|
||||||
global.productCreationData[message.author.id].step = 5;
|
global.productCreationData[message.author.id].step = 5;
|
||||||
message.channel.send('File uploaded successfully. Product creation complete.');
|
await 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) => {
|
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]);
|
||||||
if (err) {
|
await message.author.send('Product created successfully.');
|
||||||
console.error(err);
|
delete global.productCreationData[message.author.id];
|
||||||
message.channel.send('An error occurred while creating the product.');
|
delete global.dmHandlers[message.author.id];
|
||||||
cancel(message.author);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
message.author.send('Product created successfully.');
|
|
||||||
delete global.productCreationData[message.author.id];
|
|
||||||
delete global.dmHandlers[message.author.id];
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
message.channel.send('No file attached. Please upload the product file.');
|
message.channel.send('No file attached. Please upload the product file.');
|
||||||
|
|
Loading…
Reference in a new issue