Skip to content

Commit

Permalink
[v2.0.0] Release new version
Browse files Browse the repository at this point in the history
  • Loading branch information
imkuroneko authored Aug 6, 2023
1 parent e20399b commit b7433c7
Show file tree
Hide file tree
Showing 35 changed files with 2,328 additions and 2 deletions.
59 changes: 57 additions & 2 deletions README.md
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.
```
21 changes: 21 additions & 0 deletions commands/restartbot.js
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);
}
}
30 changes: 30 additions & 0 deletions commands/slashdeleter.js
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);
}
}
26 changes: 26 additions & 0 deletions commands/slashregister.js
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);
}
}
14 changes: 14 additions & 0 deletions config/params.json
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 added data/db.sqlite
Binary file not shown.
35 changes: 35 additions & 0 deletions data/embeds.json
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."
}
}

}
22 changes: 22 additions & 0 deletions ecosystem.config.js
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'
}]
}
25 changes: 25 additions & 0 deletions events/channelDelete.js
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);
}
}
};
11 changes: 11 additions & 0 deletions events/error.js
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);
}
}
31 changes: 31 additions & 0 deletions events/guildMemberRemove.js
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);
}
}
};
55 changes: 55 additions & 0 deletions events/interactionCreate.js
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);
}
}
};
36 changes: 36 additions & 0 deletions events/messageCreate.js
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);
}
}
}
Loading

0 comments on commit b7433c7

Please sign in to comment.