Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-Santana-j committed Aug 15, 2024
1 parent 0b0e3f4 commit 54d1565
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions stripe/productsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,21 @@ router.post('/product/mult', upload.fields([{ name: 'productLogo', maxCount: 1 }
var DiscordChannel = await DiscordServer.channels.cache.get(req.body.channelID)
let serverDb = await db.findOne({ colecao: 'servers', doc: req.body.serverID })

let dburl = req.files.backGround ? await functions.discordDB(req.files.backGround[0].path,client,Discord) :null
let dburl2 = null
let Newdbres2 = null
let dburl = req.files.backGround ? await functions.discordDB(req.files.backGround[0].path,client,Discord) : null
let dburl2 = req.files.productLogo ? await functions.discordDB(req.files.productLogo[0].path,client,Discord) : null
if (req.files.productLogo) {
const bannerPath = req.files.productLogo[0].path
let file = await fs.readFileSync(bannerPath);
let buffer = Buffer.from(file, 'binary');
let newBuffer = await sharp(buffer).jpeg().toBuffer()
const attachment = new Discord.AttachmentBuilder(newBuffer, { name: 'test.jpg' });
let dbBannerDiscordServer = await client.guilds.cache.get('1246186853241978911')
let dbBannerDiscordChannel = await dbBannerDiscordServer.channels.cache.get('1253279027662426142')
let dbres = await dbBannerDiscordChannel.send({
files: [attachment]
})
Newdbres2 = dbres
dburl2 = await dbres.attachments.first().url
fs.unlink(req.files.productLogo[0].path, (err) => {
if (err) {
console.error('Erro ao apagar o arquivo original:', err);
return { error: true, err: err }
} else {
return null
}
});
try {
fs.unlink(req.files.productLogo[0].path, (err) => {
if (err) {
console.error('Erro ao apagar o arquivo original:', err);
return { error: true, err: err }
} else {
return null
}
});
} catch (error) {

}
}

let productsArrayOptions = []
Expand Down

0 comments on commit 54d1565

Please sign in to comment.