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 13, 2024
1 parent 0b681cc commit 30e86ec
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ config/web-config.js
config
config/mercadoPagoData.json


/uploads
/cart.list
4 changes: 2 additions & 2 deletions Discord/createProductMessageEmbend.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ module.exports = async (Discord2, client, data) => {
}
let backGroundLink = ''
let logoLink = ''
logoLink = produto.productLogo ? await functions.discordDB(produto.productLogo,client,Discord) : ``
backGroundLink = produto.backGround ? await functions.discordDB(produto.backGround,client,Discord) : ``
logoLink = produto.productLogo ? await functions.discordDB(produto.productLogo,client,Discord) : null
backGroundLink = produto.backGround ? await functions.discordDB(produto.backGround,client,Discord) : null

let embed = await DiscordChannel.send({
embeds: [
Expand Down
21 changes: 4 additions & 17 deletions Discord/createTicketMensage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
let Discord = require('discord.js')
let db = require('../Firebase/models')
let webConfig = require('../config/web-config')
let botConfig = require('../config/bot-config')
const path = require('path')
const fs = require('fs')
const sharp = require('sharp')
const functions = require('../functions')

module.exports = async (client, channelID, serverID) => {
try {
Expand All @@ -28,23 +30,8 @@ module.exports = async (client, channelID, serverID) => {
)
}
}
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
}

let dburl = serverData.ticketOptions.banner ? await functions.discordDB(serverData.ticketOptions.banner,client,Discord) : null

//salvar essa url no banco de dados para nao precisar ta criando toda hora uma nova mensagem
await DiscordChannel.send({
embeds: [
Expand Down
351 changes: 178 additions & 173 deletions Discord/discordIndex.js

Large diffs are not rendered by default.

24 changes: 3 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,6 @@ client.on(Events.ShardError, error => {
console.error('A websocket connection encountered an error:', error);
});

process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});

process.on('unhandRejection', (reason, promise) => {
console.log(`🚫 Erro Detectado:\n\n` + reason, promise)
});

process.on('uncaughtException', (error, origin) => {
console.log(`🚫 Erro Detectado:\n\n` + error, origin)
});

process.on('uncaughtExceptionMonitor', (error, origin) => {
console.log(`🚫 Erro Detectado:\n\n` + error, origin)
});





//TODO------------WEB PAGE--------------
Expand Down Expand Up @@ -991,7 +973,7 @@ app.post('/personalize/welcomeActive', async (req, res) => {
if (server) {
server.personalize.welcomeMensage.active = true
db.update('servers', req.body.serverID, {
personalize: personalize
personalize: server.personalize
})
if (!res.headersSent) {
res.status(200).json({ success: true, })
Expand All @@ -1014,7 +996,7 @@ app.post('/personalize/welcomeDesactive', async (req, res) => {
if (server) {
server.personalize.welcomeMensage.active = false
db.update('servers', req.body.serverID, {
personalize: personalize
personalize: server.personalize
})
if (!res.headersSent) {
res.status(200).json({ success: true, })
Expand Down Expand Up @@ -1277,7 +1259,7 @@ app.post('/ticket/banner', upload.single('BannerTicket'), async (req, res) => {
ticketOptions: ticketOptions
})
if (ticketOptions.channel) {
require('./Discord/createTicketMensage.js')(client, ticketOptions.channel, body.serverID)
require('./Discord/createTicketMensage.js')(client, ticketOptions.channel, req.body.serverID)
}
if (!res.headersSent) {
res.status(200).json({ success: true, data: 'Banner Alterado!' })
Expand Down
20 changes: 16 additions & 4 deletions public/js/personalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ document.getElementById('welcome-channel-input').addEventListener('blur', functi
}
});
document.getElementById('save-mensage-welcome').addEventListener('click',async()=>{
if (document.getElementById(`title-welcome`).value.trim().length <= 0) {
errorNotify(`Insira um titulo primeiro!`)
return
}
if (document.getElementById(`mensage-welcome`).value.trim().length <= 0) {
errorNotify(`Insira uma mensagem primeiro!`)
return
}
if (document.getElementById(`welcome-channel-input`).value.trim().length <= 0) {
errorNotify(`Insira um canal primeiro!`)
return
}
const opcoes = document.getElementById('welcome-channel-list').querySelectorAll('option');
let channelID = null;

Expand Down Expand Up @@ -186,8 +198,8 @@ document.getElementById('desative-welcome').addEventListener('click',async()=>{
}).then(response => { return response.json() })
if (session.success == true) {
successNotify('Mensagem de boas vindas desativada!')
document.getElementById(`active-welcome`).classList.add(`hidden`)
document.getElementById(`desative-welcome`).classList.remove(`hidden`)
document.getElementById(`active-welcome`).classList.remove(`hidden`)
document.getElementById(`desative-welcome`).classList.add(`hidden`)
}else{
errorNotify(session.data)
}
Expand All @@ -205,8 +217,8 @@ document.getElementById('active-welcome').addEventListener('click',async()=>{
}).then(response => { return response.json() })
if (session.success == true) {
successNotify('Mensagem de boas vindas ativada!')
document.getElementById(`active-welcome`).classList.remove(`hidden`)
document.getElementById(`desative-welcome`).classList.add(`hidden`)
document.getElementById(`active-welcome`).classList.add(`hidden`)
document.getElementById(`desative-welcome`).classList.remove(`hidden`)
}else{
errorNotify(session.data)
}
Expand Down
13 changes: 13 additions & 0 deletions public/js/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ document.getElementById('motivo-responsavel-ticket-edit').addEventListener('blur
});

document.getElementById('save-channel-ticket').addEventListener('click',async()=>{
let server = await fetch('/get/server', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
serverID:serverID
}),
}).then(response => { return response.json() })
if (server.success == true && `ticketOptions` in server.data && server.data.ticketOptions.motivos.length <= 0) {
errorNotify(`Cadastre um motivo primeiro!`)
return
}
if (document.getElementById('bot-ticket-channel').value <= 0) {
errorNotify('Selecione um canal primeiro!')
return
Expand Down
4 changes: 2 additions & 2 deletions views/personalize.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@
<% } %>
<div class="inputs-col-content">
<label for="title-welcome" class="lable-padrao">Titulo da mensagem!</label>
<input required type="text" class="input-padrao" placeholder="Titulo" id="title-welcome">
<input required type="text" value="<%= 'personalize' in server && 'welcomeMensage' in server.personalize ? server.personalize.welcomeMensage.title :''%>" class="input-padrao" placeholder="Titulo" id="title-welcome">
</div>
<div class="inputs-col-content">
<label for="mensage-welcome" class="lable-padrao">Mensagem de boas vindas!</label>
<input required type="text" class="input-padrao" placeholder="Mensagem" id="mensage-welcome">
<input required type="text" value="<%= 'personalize' in server && 'welcomeMensage' in server.personalize ? server.personalize.welcomeMensage.mensage :''%>" class="input-padrao" placeholder="Mensagem" id="mensage-welcome">
</div>
<div class="inputs-col-content">
<label for="welcome-channel-input" class="lable-padrao">Canal de boas vindas!</label>
Expand Down

0 comments on commit 30e86ec

Please sign in to comment.