Skip to content

Commit

Permalink
Merge pull request #13 from Fernando-Santana-j/development
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
Fernando-Santana-j authored Jun 20, 2024
2 parents 93765a9 + b3fa6b2 commit 54da9f1
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Discord/createCartMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = async (Discord, client, data) => {
.setDescription(`Clique em cancelar caso desista de fazer a compra.
Abaixo são os itens do seu carrinho.`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.addFields(...[...fields, { name: '\u200B', value: '\u200B' },])
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.setThumbnail(`https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp`)
Expand Down
47 changes: 30 additions & 17 deletions Discord/createTicketMensage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
let Discord = require('discord.js')
let db = require('../Firebase/models')
let webConfig = require('../config/web-config')
const path = require('path')
const fs = require('fs')
const sharp = require('sharp')

module.exports = async (client, channelID, serverID) => {
try {
Expand All @@ -9,11 +12,11 @@ module.exports = async (client, channelID, serverID) => {
let serverData = await db.findOne({ colecao: 'servers', doc: serverID })
try {
const fetched = await DiscordChannel.messages.fetch({ limit: 100 });
DiscordChannel.bulkDelete(fetched).catch(()=>{})
} catch (error) {}
await fetched.forEach(element => {
element.delete()
});
} catch (error) { console.log(error); }
let motivoFields = []
let ticketBanner = `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp`

if (serverData && 'ticketOptions' in serverData) {
for (let index = 0; index < serverData.ticketOptions.motivos.length; index++) {
const element = serverData.ticketOptions.motivos[index];
Expand All @@ -24,20 +27,33 @@ module.exports = async (client, channelID, serverID) => {
.setValue(element.id)
)
}
if (serverData.ticketOptions.banner) {
ticketBanner = `${webConfig.host}${serverData.ticketOptions.banner}`
}
}
let dburl = null
let Newdbres = null
if (serverData && 'ticketOptions' in serverData && 'banner' in serverData.ticketOptions) {
const bannerPath = path.join(__dirname, '..', serverData.ticketOptions.banner);
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]
})
Newdbres = dbres
dburl = await dbres.attachments.first().url
}

//salvar essa url no banco de dados para nao precisar ta criando toda hora uma nova mensagem
await DiscordChannel.send({
embeds: [
new Discord.EmbedBuilder()
.setTitle(`Está enfrentando algum problema com a ${DiscordServer.name}?`)
.setDescription(`Abaixo você pode criar um ticket para que seu problema seja solucionado basta selecionar seu idioma e oque esta acontecendo e criar seu ticket!`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('#6E58C7')
.setDescription(serverData && 'ticketOptions' in serverData && 'desc' in serverData.ticketOptions ? serverData.ticketOptions.desc : 'Abaixo você pode criar um ticket para que seu problema seja solucionado basta selecionar seu idioma e oque esta acontecendo e criar seu ticket!' )
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.setTimestamp()
.setImage(ticketBanner)
.setImage(dburl)
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
],
components: [
Expand Down Expand Up @@ -128,14 +144,11 @@ module.exports = async (client, channelID, serverID) => {
.setMaxValues(1)
.addOptions(...motivoFields)
),
// new Discord.ActionRowBuilder().addComponents(
// new Discord.ButtonBuilder()
// .setCustomId(`createTicket`)
// .setLabel('🎫 Criar Ticket')
// .setStyle('3'),
// )
],
})
// if (Newdbres) {
// Newdbres.delete()
// }
} catch (error) {
console.log(error);
}
Expand Down
18 changes: 9 additions & 9 deletions Discord/discordIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module.exports = (Discord2, client) => {
new Discord.EmbedBuilder()
.setTitle('Selecione abaixo o item que deseja excluir!')
.setDescription(`Clique em cancelar caso desista de excluir um item!`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7')
.setThumbnail(`https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp`)
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
Expand Down Expand Up @@ -559,7 +559,7 @@ module.exports = (Discord2, client) => {
.setDescription(`Pix Copiar e Colar:
${'**```' + cpc + '```**'}`)
.setImage('attachment://qrcodepix.png')
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
],
components: [new Discord.ActionRowBuilder()
Expand Down Expand Up @@ -712,7 +712,7 @@ module.exports = (Discord2, client) => {
.setTitle(`🛍️ | Você recebeu um produto!`)
.setDescription(`Você recebeu um novo produto de ${SendUser.globalName}`)
.addFields(...fields)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7')
.setTimestamp()
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp ` })
Expand All @@ -724,7 +724,7 @@ module.exports = (Discord2, client) => {
.setTitle(`✅ | Produto enviado!`)
.setDescription(`Você enviou um produto para ${user.globalName} Abaixo esta uma copia do que foi enviado:`)
.addFields(...fields)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7')
.setTimestamp()
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp ` })
Expand Down Expand Up @@ -1597,7 +1597,7 @@ module.exports.sendProductPayment = async (params, id, type) => {
new Discord.EmbedBuilder()
.setTitle('📦 | Sua entrega chegou!')
.setDescription(`Abaixo estão os dados da sua entrega:`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
],
Expand Down Expand Up @@ -1628,7 +1628,7 @@ module.exports.sendProductPayment = async (params, id, type) => {
{ name: '\u200B', value: '\u200B' },
...fields
)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
],
Expand All @@ -1641,7 +1641,7 @@ module.exports.sendProductPayment = async (params, id, type) => {
new Discord.EmbedBuilder()
.setTitle('📦 | Sua entrega chegou!')
.setDescription(`Abaixo estão os dados da sua entrega:`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.addFields(...fields)
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
Expand All @@ -1654,7 +1654,7 @@ module.exports.sendProductPayment = async (params, id, type) => {
new Discord.EmbedBuilder()
.setTitle('📦 | Sua entrega chegou!')
.setDescription(`Enviamos a entrega no seu privado caso não tenha recebido o seu privado pode esta bloqueado então tenha certeza de baixar os arquivos antes que o carrinho seja fechado`)
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.addFields(...fields)
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` })
Expand Down Expand Up @@ -1712,7 +1712,7 @@ module.exports.sendProductPayment = async (params, id, type) => {
.setTitle(`🛍️ | Nova compra!`)
.setDescription(`Uma nova compra foi feita abaixo está os dados da compra:`)
.addFields(...allfieldsPublic)
.setAuthor({ name: user.globalName, iconURL: userPic })
// .setAuthor({ name: user.globalName, iconURL: userPic })
.setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7')
.setTimestamp()
.setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp ` })
Expand Down
44 changes: 43 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ app.post('/ticket/motivoADD', async (req, res) => {
db.update('servers', body.serverID, {
ticketOptions: ticketOptions
})

if (ticketOptions.channel) {
require('./Discord/createTicketMensage.js')(client, ticketOptions.channel, body.serverID)
}
Expand Down Expand Up @@ -1180,6 +1181,9 @@ app.post('/ticket/banner', upload.single('BannerTicket'), async (req, res) => {
db.update('servers', req.body.serverID, {
ticketOptions: ticketOptions
})
if (ticketOptions.channel) {
require('./Discord/createTicketMensage.js')(client, ticketOptions.channel, body.serverID)
}
if (!res.headersSent) {
res.status(200).json({ success: true, data: 'Banner Alterado!' })
}
Expand Down Expand Up @@ -1259,6 +1263,7 @@ app.post('/ticket/privatelog', async (req, res) => {
db.update('servers', body.serverID, {
ticketOptions: ticketOptions
})

if (!res.headersSent) {
res.status(200).json({ success: true, data: 'Log privado modificado!' })
}
Expand All @@ -1269,6 +1274,43 @@ app.post('/ticket/privatelog', async (req, res) => {
console.log(error);
}
})
app.post('/ticket/desc', async (req, res) => {
try {
let body = await req.body
let server = await db.findOne({ colecao: 'servers', doc: body.serverID })
let ticketOptions = {
motivos: [],
channel: '',
atend: {
start: '',
end: '',
days: []
},
avaliacao: '',
log: '',
privateLog: '',
desc:''
}
if ('ticketOptions' in server) {
ticketOptions = server.ticketOptions
}
ticketOptions.desc = body.desc
db.update('servers', body.serverID, {
ticketOptions: ticketOptions
})
if (ticketOptions.channel) {
require('./Discord/createTicketMensage.js')(client, ticketOptions.channel, body.serverID)
}
if (!res.headersSent) {
res.status(200).json({ success: true, data: 'Descrição modificado!' })
}
} catch (error) {
if (!res.headersSent) {
res.status(200).json({ success: false, data: 'Erro ao tentar modificar a descrição do ticket!' })
}
console.log(error);
}
})
app.post('/ticket/publiclog', async (req, res) => {
try {
let body = await req.body
Expand Down Expand Up @@ -1344,7 +1386,7 @@ app.post('/send/discordMensage', async (req, res) => {
.setDescription(`\n${textTranslate}\n`)
.addFields({ name: '\u200B', value: '\u200B' }, { name: 'Tipo', value: `${req.body.admin == true ? "administrador" : "usuario"}`, inline: true }, { name: "Nome do usuario", value: user.username, inline: true }, { name: "ID do usuario", value: user.id, inline: true })
.setColor('#6E58C7')
.setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
// .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`, url: 'https://discord.gg/jVuVx4PEju' })
.setTimestamp()

]
Expand Down
29 changes: 28 additions & 1 deletion public/css/analytics.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,31 @@
gap: 2em;
margin-top: 1em;
justify-content: space-between;
}
}


@media screen and (max-width:1040px) {
#main-content{
width: 100% !important;
height: auto !important;
gap: 2em !important;
}
#main-containner{
width: 100% !important;
height: auto !important;
left: 0 !important;
}

}

@media screen and (max-width:800px) {
.charts-content{
flex-direction: column;
gap: 1em !important;
width: 100% !important;
}
#vendas-completas-chart,#vendas-canceladas-chart,#reebolso-chart,#estoque-chart,#payment-chart{
width: 90% !important;
}
}

14 changes: 14 additions & 0 deletions public/css/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,18 @@
#block-bank-button{
width: 15em;
margin-top: 17px;
}

@media screen and (max-width:1040px) {
#main-content{
width: 100% !important;
height: auto !important;
gap: 2em !important;
}
#main-containner{
width: 100% !important;
height: auto !important;
left: 0 !important;
}

}
Loading

0 comments on commit 54da9f1

Please sign in to comment.