-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e20399b
commit b7433c7
Showing
35 changed files
with
2,328 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
# AnneTicketHelper | ||
🎫 Bot de tickets para Discord v2 | ||
<h2 align="center"> 🎫 AnneTicketHelper </h2> | ||
|
||
<pre align="center"> | ||
Sistema de tickets de soporte para discord (v2) | ||
</pre> | ||
|
||
<br> | ||
|
||
|
||
### 🧰 Dependencias Utilizadas | ||
``` | ||
• DiscordJS v14 | ||
• SQLite (BetterSQLite) | ||
• fs (para la lectura de los ficheros necesarios) | ||
• os & cpu-stat (para monitoreo de recursos) | ||
``` | ||
<br> | ||
|
||
### 📋 Como Instalar | ||
```php | ||
npm install # instalar las dependencias | ||
npm update # actualizar las dependencias | ||
``` | ||
<br> | ||
|
||
### 🔍 Info adicional | ||
``` | ||
Recuerda modificar en el archivo "ecosystem.config.js" el nombre | ||
Este es el que aparecerá en el monitor de pm2 | ||
``` | ||
<br> | ||
|
||
### 📋 PM2 | ||
``` | ||
pm2 start | ||
``` | ||
<br> | ||
|
||
### 📚 Comandos Disponibles | ||
``` | ||
Coming Soon | ||
``` | ||
<br> | ||
|
||
|
||
### 📖 Documentación | ||
``` | ||
Coming Soon | ||
``` | ||
<br> | ||
|
||
|
||
### 📄 Licencia y Derechos | ||
``` | ||
Todos los derechos reservados para el trabajo realizado. <br> | ||
Se respetan así también los derechos y las licencias a todas las dependencias utilizadas en la realización de este proyecto. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const path = require('path'); | ||
|
||
// Load configuration files ================================================================================================ | ||
const { ownerId } = require(path.resolve('./config/params.json')); | ||
|
||
// Module script =========================================================================================================== | ||
exports.run = (client, message, args) => { | ||
try { | ||
if(message.author.id != ownerId) { return; } | ||
|
||
message.reply('🦄 Reiniciando bot~'); | ||
|
||
setTimeout(() => { | ||
process.exit(); | ||
}, 2500); | ||
} catch(error) { | ||
console.error(color.red('[cmdPrefix:restartbot]'), error.message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const path = require('path'); | ||
const { Routes } = require('discord.js'); | ||
const { REST } = require('@discordjs/rest'); | ||
|
||
// Load configuration files ================================================================================================ | ||
const { clientId, ownerId, token } = require(path.resolve('./config/params.json')) | ||
|
||
// Module script =========================================================================================================== | ||
exports.run = (client, message, args) => { | ||
try { | ||
if(message.author.id != ownerId) { return; } | ||
|
||
const rest = new REST({ version: '10' }).setToken(token); | ||
|
||
rest.get(Routes.applicationCommands(clientId)).then((data) => { | ||
const promises = []; | ||
for(const command of data) { | ||
const deleteUrl = `${Routes.applicationCommands(clientId)}/${command.id}`; | ||
promises.push(rest.delete(deleteUrl)); | ||
} | ||
Promise.all(promises); | ||
}); | ||
|
||
return message.reply('🦄 Todos los comandos slash fueron eliminados'); | ||
} catch(error) { | ||
console.error(color.red('[cmdPrefix:slashdeleter]'), error.message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const path = require('path'); | ||
const { Routes } = require('discord.js'); | ||
const { REST } = require('@discordjs/rest'); | ||
|
||
// Load configuration files ================================================================================================ | ||
const { clientId, ownerId, token } = require(path.resolve('./config/params.json')) | ||
|
||
// Module script =========================================================================================================== | ||
exports.run = (client, message, args) => { | ||
try { | ||
if(message.author.id != ownerId) { return; } | ||
|
||
const rest = new REST({ version: '10' }).setToken(token); | ||
|
||
rest.put(Routes.applicationCommands(clientId), { body: client.slashRegister }).then(() => { | ||
message.reply('🦄 Todos los comandos fueron registrados/actualizados!'); | ||
}).catch((error) => { | ||
message.reply(`\`[🦄 cmdPrefix:slashregister]\` ${error.message}`); | ||
console.error(color.red('[cmdPrefix:slashregister]'), error.message); | ||
}); | ||
} catch(error) { | ||
console.error(color.red('[cmdPrefix:slashregister]'), error.message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"clientId" : "", | ||
"token" : "", | ||
|
||
"ownerId" : "", | ||
|
||
"prefix" : "$", | ||
|
||
"serverTimezone" : "", | ||
|
||
"staffRole" : "", | ||
"secDelTicket" : 10, | ||
"deleteTicketOnLeft" : true | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"footer" : { | ||
"url" : "https://unicodesoft.net", | ||
"text" : "🦄 by Unicodesoft | Todos los derechos reservados" | ||
}, | ||
|
||
"template" : { | ||
"main_embed" : { | ||
"color" : "03cafc", | ||
"title" : "🎫 Sistema de Soporte", | ||
"description" : "Para abrir un ticket de soporte, selecciona en la lista de abajo la categoría mas adecuada y nuestro staff te estará atendiendo en la brevedad posible." | ||
}, | ||
"new" : { | ||
"color" : "03cafc", | ||
"title" : "Bienvenido a nuestro sistema de tickets para {catname_mention}!", | ||
"description" : "Por favor explayese lo mas posible por este medio y, uno de nuestros staff te estará ayudando en la brevedad.\n Si abriste este ticket por error, utiliza el siguiente comando: `/eliminar`" | ||
}, | ||
"closed" : { | ||
"color" : "943737", | ||
"title" : "📘 Ticket Cerrado", | ||
"description" : "El ticket ha sido marcado como cerrado; para eliminarlo utilice el comando `/eliminar` o, `/reabrir` para abrir nuevamente el ticket." | ||
}, | ||
"reopened" : { | ||
"color" : "9ed654", | ||
"title" : "📖 Ticket Reabierto", | ||
"description" : "El ticket ha sido abierto nuevamente por un staff." | ||
}, | ||
"delete" : { | ||
"color" : "5e3794", | ||
"title" : "🗑 Ticket Culminado", | ||
"description" : "Este ticket será eliminado en {seconds} segundos." | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
apps : [{ | ||
name : "AyamiTicketHelper", | ||
script : "./index.js", | ||
|
||
watch : true, | ||
max_restarts : 10, | ||
|
||
// Ficheros a ignorar (para evitar el bot se reinicie cuando estos ficheros sean modificados) | ||
ignore_watch : [ | ||
'./data/embeds.json', | ||
'./config/params.json', | ||
'./data/db.sqlite', | ||
'./logs/errors.log', | ||
'./logs/out.log' | ||
], | ||
|
||
log_date_format : 'YYYY-MM-DD HH:mm', | ||
error_file : './logs/errors.log', | ||
out_file : './logs/out.log' | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const { Events } = require('discord.js'); | ||
const path = require('path'); | ||
|
||
// Load SQLite Helper ====================================================================================================== | ||
const sqlite = require(path.resolve('./functions/sqlite.js')) | ||
|
||
// Module script =========================================================================================================== | ||
module.exports = { | ||
name: Events.ChannelDelete, | ||
async execute(channel) { | ||
try { | ||
const guildId = channel.guildId; | ||
const channelId = channel.id; | ||
|
||
const validateTicket = await sqlite.isTicket(guildId, channelId); | ||
if(!validateTicket) { return; } | ||
|
||
await sqlite.updateStatus(guildId, channelId, 'deleted'); | ||
} catch(error) { | ||
console.error(color.red('[event:channelDelete]'), error.message); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const { Events } = require('discord.js'); | ||
|
||
// Module script =========================================================================================================== | ||
module.exports = { | ||
name: Events.Error, | ||
async execute(error) { | ||
console.error(color.red('[djs] mainErrorTracker'), error.message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const { Events } = require('discord.js'); | ||
const path = require('path'); | ||
|
||
// Load configuration files ================================================================================================ | ||
const { deleteTicketOnLeft } = require(path.resolve('./config/params.json')); | ||
|
||
// Load SQLite Helper ====================================================================================================== | ||
const sqlite = require(path.resolve('./functions/sqlite.js')) | ||
|
||
// Module script =========================================================================================================== | ||
module.exports = { | ||
name: Events.GuildMemberRemove, | ||
async execute(member) { | ||
try { | ||
const userId = member.user.id; | ||
const guildId = member.guild.id; | ||
|
||
if(deleteTicketOnLeft) { | ||
const channelsToClose = await sqlite.getTicketsMemberLeft(guildId, userId); | ||
channelsToClose.forEach(async (ticket) => { | ||
const channelDel = await member.guild.channels.cache.get(ticket.channel); | ||
channelDel.delete(); | ||
}); | ||
} | ||
} catch(error) { | ||
console.error(color.red('[event:guildMemberRemove]'), error.message); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const { Events } = require('discord.js'); | ||
|
||
// Module script =========================================================================================================== | ||
module.exports = { | ||
name: Events.InteractionCreate, | ||
async execute(interaction) { | ||
try { | ||
if(interaction.isChatInputCommand()) { | ||
try { | ||
const command = interaction.client.interactionsSlash.get(interaction.commandName); | ||
if(!command) { return; } | ||
|
||
await command.execute(interaction); | ||
} catch(error) { | ||
console.error(color.red('event:interactionCreate:command'), error.message); | ||
return interaction.reply({ content: 'oops! hubo un error al ejecutar el evento slash 😣', ephemeral: true }); | ||
} | ||
} | ||
|
||
if(interaction.isStringSelectMenu()) { | ||
try { | ||
var optionId = interaction.values[0]; | ||
var interactionName = optionId.split(';'); | ||
|
||
const menuAction = interaction.client.interactionsSelectMenu.get(interactionName[0]); | ||
if(!menuAction) { return; } | ||
|
||
await menuAction.execute(interaction); | ||
} catch(error) { | ||
console.error(color.red('event:interactionCreate:select'), error.message); | ||
return interaction.reply({ content: 'oops! hubo un error al ejecutar el evento menu 😣', ephemeral: true }); | ||
} | ||
} | ||
|
||
if(interaction.isButton()) { | ||
try { | ||
var data = interaction.customId.split(';'); | ||
var buttonActions = data[0]; | ||
|
||
const btnAction = interaction.client.interactionsButtons.get(buttonActions); | ||
if(!btnAction) { return; } | ||
|
||
await btnAction.execute(interaction); | ||
} catch(error) { | ||
console.error(color.red('event:interactionCreate:button'), error.message); | ||
return interaction.reply({ content: 'oops! hubo un error al ejecutar el evento button 😣', ephemeral: true }); | ||
} | ||
} | ||
} catch(error) { | ||
console.error(color.red('[event:interactionCreate]'), error.message); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Load required resources ================================================================================================= | ||
const { color } = require('console-log-colors'); | ||
const { Events } = require('discord.js'); | ||
const path = require('path'); | ||
|
||
// Load configuration files ================================================================================================ | ||
const config = require(path.resolve('./config/params.json')); | ||
|
||
// Module script =========================================================================================================== | ||
module.exports = { | ||
name: Events.MessageCreate, | ||
async execute(message) { | ||
try { | ||
// 🚨 Ignore bots | ||
if(message.author.bot) { return; } | ||
|
||
// 🚨 Ignore when not prefix | ||
if(message.content.indexOf(config.prefix) !== 0) { | ||
return; | ||
} | ||
|
||
// 🥞 Split content | ||
const args = message.content.slice(config.prefix.length).trim().split(/ +/g); | ||
const command = args.shift().toLowerCase(); | ||
|
||
// 🔍 Search command | ||
const cmd = message.client.commandsPrefix.get(command); | ||
|
||
if(!cmd) { return; } | ||
|
||
cmd.run(message.client, message, args); | ||
} catch(error) { | ||
console.error(color.red('[event:messageCreate]'), error.message); | ||
} | ||
} | ||
} |
Oops, something went wrong.