From 220c0f0a135844aa7be75f600ab7d288e6b4ddc3 Mon Sep 17 00:00:00 2001 From: KuroNeko Date: Sat, 29 Jul 2023 16:32:13 -0400 Subject: [PATCH] [v3.2.0] Agregado i18n; Mejorado !embedroles --- commands/admin/embedroles.js | 82 ++++++++++--------- config/bot.js | 3 +- config/roles.js | 22 ++--- data/i18n/members.js | 19 +++++ data/i18n/roles.js | 15 ++++ .../i18n/tickets.json => i18n/tickets.js} | 5 +- data/json/i18n/members.json | 18 ---- ecosystem.config.js | 2 +- events/members/guildMemberAdd.js | 38 +++++---- events/members/guildMemberRemove.js | 16 ++-- interactions/buttons/tickets/closeTicket.js | 2 +- interactions/buttons/tickets/deleteTicket.js | 2 +- interactions/buttons/tickets/reopenTicket.js | 2 +- .../selectMenu/tickets/createTicket.js | 2 +- interactions/slashCommands/misc/host.js | 2 +- interactions/slashCommands/misc/nuggots.js | 2 +- interactions/slashCommands/misc/server.js | 1 - .../tickets/categorias_modificar.js | 1 - .../slashCommands/tickets/tickets_cerrar.js | 2 +- .../slashCommands/tickets/tickets_eliminar.js | 2 +- .../slashCommands/tickets/tickets_reabrir.js | 2 +- package.json | 2 +- to_do.md | 4 - 23 files changed, 137 insertions(+), 109 deletions(-) create mode 100644 data/i18n/members.js create mode 100644 data/i18n/roles.js rename data/{json/i18n/tickets.json => i18n/tickets.js} (95%) delete mode 100644 data/json/i18n/members.json delete mode 100644 to_do.md diff --git a/commands/admin/embedroles.js b/commands/admin/embedroles.js index 6254cbc..5673b03 100644 --- a/commands/admin/embedroles.js +++ b/commands/admin/embedroles.js @@ -3,7 +3,9 @@ const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const path = require('path'); // Load configuration files ================================================================================================ -const { ownerId } = require(path.resolve('./config/bot')); +const { ownerId, embedColor } = require(path.resolve('./config/bot')); +const embedRoles = require(path.resolve('./data/i18n/roles')); +const roles = require(path.resolve('./config/roles')); // Module script =========================================================================================================== exports.run = (client, message, args) => { @@ -12,43 +14,47 @@ exports.run = (client, message, args) => { return message.reply("🚨 **no tienes permiso para ejecutar este comando!**"); } - // ======================= Roles de alertas ======================== - message.channel.send({ embeds: [{ - color: 0xc676f5, - title: '**📣 Roles de Alertas**', - description: 'Si deseas recibir alertas específicas, haz clic en los botones de abajo para recibir el rol y estar al tanto de ello', - }], components: [ new ActionRowBuilder().addComponents( - new ButtonBuilder().setCustomId('rolesManager;665208554726359064').setLabel('RaffleAlert').setStyle(ButtonStyle.Secondary).setEmoji('🎫'), - new ButtonBuilder().setCustomId('rolesManager;606674875557478416').setLabel('StreamAlert').setStyle(ButtonStyle.Secondary).setEmoji('🎥'), - ) ] }); - - - // ======================= Roles de hobbies ======================== - message.channel.send({ embeds: [{ - color: 0xc676f5, - title: '**🌌 Roles de Hobbies**', - description: 'Haz clic en los botones de abajo para recibir el rol de cada hobbie con el que te identifiques', - }], components: [ new ActionRowBuilder().addComponents( - new ButtonBuilder().setCustomId('rolesManager;461330378691444767').setLabel('Developer').setStyle(ButtonStyle.Secondary).setEmoji('💻'), - new ButtonBuilder().setCustomId('rolesManager;488012857909182464').setLabel('Artist').setStyle(ButtonStyle.Secondary).setEmoji('🎨'), - new ButtonBuilder().setCustomId('rolesManager;467854409284452362').setLabel('Gamer').setStyle(ButtonStyle.Secondary).setEmoji('🎮'), - new ButtonBuilder().setCustomId('rolesManager;528826642156748802').setLabel('Streamer').setStyle(ButtonStyle.Secondary).setEmoji('🎥'), - ) ] }); - - - // ==================== Roles de colores únicos ==================== - message.channel.send({ embeds: [{ - color: 0xc676f5, - title: '**🎨 Roles de Colores**', - description: 'Haz clic en los botones de abajo para tener el rol con el color que mas te guste', - }], components: [ new ActionRowBuilder().addComponents( - new ButtonBuilder().setCustomId('rolesManager;908324747098595368').setLabel('#93b97d').setStyle(ButtonStyle.Secondary).setEmoji('878063019022753813'), - new ButtonBuilder().setCustomId('rolesManager;908324738252820520').setLabel('#66c1bc').setStyle(ButtonStyle.Secondary).setEmoji('878063019182145536'), - new ButtonBuilder().setCustomId('rolesManager;908324743814467595').setLabel('#ebda79').setStyle(ButtonStyle.Secondary).setEmoji('878063019110850610'), - new ButtonBuilder().setCustomId('rolesManager;908324749615181824').setLabel('#7982ef').setStyle(ButtonStyle.Secondary).setEmoji('878063019110838312'), - new ButtonBuilder().setCustomId('rolesManager;908324733706207303').setLabel('#ef7993').setStyle(ButtonStyle.Secondary).setEmoji('878063018955636747'), - ) ] }); - + const stackable = roles.stackables; + Object.keys(stackable).forEach(key => { + if(!embedRoles[key]) { return; } + + let buttonsRoles = []; + stackable[key].forEach((rol) => { + buttonsRoles.push(new ButtonBuilder().setCustomId(`rolesManager;${rol.id}`).setLabel(rol.name).setStyle(ButtonStyle.Secondary).setEmoji(rol.emoji)); + }); + + message.channel.send({ + embeds: [{ + color: parseInt(embedColor, 16), + title: embedRoles[key].title, + description: embedRoles[key].description, + }], + components: [ new ActionRowBuilder().addComponents(buttonsRoles) ] + }).catch((error) => { + console.error('[cmdPrefix:embedroles:stackable]', error.message); + }); + }); + + const unique = roles.unique; + Object.keys(unique).forEach(key => { + if(!embedRoles[key]) { return; } + + let buttonsRoles = []; + unique[key].forEach((rol) => { + buttonsRoles.push(new ButtonBuilder().setCustomId(`rolesManager;${rol.id}`).setLabel(rol.name).setStyle(ButtonStyle.Secondary).setEmoji(rol.emoji)); + }); + + message.channel.send({ + embeds: [{ + color: parseInt(embedColor, 16), + title: embedRoles[key].title, + description: embedRoles[key].description, + }], + components: [ new ActionRowBuilder().addComponents(buttonsRoles) ] + }).catch((error) => { + console.error('[cmdPrefix:embedroles:unique]', error.message); + }); + }); } catch(error) { console.error('[cmdPrefix:embedroles]', error.message); } diff --git a/config/bot.js b/config/bot.js index 97328f5..5c48dd1 100644 --- a/config/bot.js +++ b/config/bot.js @@ -18,7 +18,8 @@ module.exports = { "embedColor" : "cc3366", // Se envía con imagen el mensaje de bienvenida? - "welcomeHasImage" : false, + "welcomeSendImage" : true, + "welcomeSendEmbed" : true, // Zona horaria para cronjobs "timezoneSv" : "America/Asuncion" diff --git a/config/roles.js b/config/roles.js index 3bce9e1..a9f5a01 100644 --- a/config/roles.js +++ b/config/roles.js @@ -6,25 +6,25 @@ module.exports = { // Roles que se pueden acumular por categoría "stackables" : { "alertas" : [ - { "name" : "🎫⠀RaffleAlert", "id" : "665208554726359064" }, - { "name" : "🎥⠀StreamAlert", "id" : "606674875557478416" } + { "name" : "RaffleAlert", "id" : "665208554726359064", "emoji": "🎫" }, + { "name" : "StreamAlert", "id" : "606674875557478416", "emoji": "🎥" } ], "hobbies" : [ - { "name" : "💻⠀Developer", "id" : "461330378691444767" }, - { "name" : "🎨⠀Artist", "id" : "488012857909182464" }, - { "name" : "🎮⠀Gamer", "id" : "467854409284452362" }, - { "name" : "🎥⠀Streamer", "id" : "528826642156748802" } + { "name" : "Developer", "id" : "461330378691444767", "emoji": "💻" }, + { "name" : "Artist", "id" : "488012857909182464", "emoji": "🎨" }, + { "name" : "Gamer", "id" : "467854409284452362", "emoji": "🎮" }, + { "name" : "Streamer", "id" : "528826642156748802", "emoji": "🎥" } ] }, // Roles únicos por categoría "unique" : { "colores" : [ - { "name" : "#93b97d", "id" : "908324747098595368" }, - { "name" : "#66c1bc", "id" : "908324738252820520" }, - { "name" : "#ebda79", "id" : "908324743814467595" }, - { "name" : "#7982ef", "id" : "908324749615181824" }, - { "name" : "#ef7993", "id" : "908324733706207303" } + { "name" : "#93b97d", "id" : "908324747098595368", "emoji" : "878063019022753813" }, + { "name" : "#66c1bc", "id" : "908324738252820520", "emoji" : "878063019182145536" }, + { "name" : "#ebda79", "id" : "908324743814467595", "emoji" : "878063019110850610" }, + { "name" : "#7982ef", "id" : "908324749615181824", "emoji" : "878063019110838312" }, + { "name" : "#ef7993", "id" : "908324733706207303", "emoji" : "878063018955636747" } ] } } \ No newline at end of file diff --git a/data/i18n/members.js b/data/i18n/members.js new file mode 100644 index 0000000..c33132d --- /dev/null +++ b/data/i18n/members.js @@ -0,0 +1,19 @@ +module.exports = { + // ==== on:guildMemberAdd + "memberJoinPublic" : { + "title" : "", + "description" : + "Bienvenido al servidor 👋🏻 Esperamos disfrutes tu estadía en el servidor.\n\n"+ + "**Sobre Mí:** <#637941772063866890>\n"+ + "**Reglas del servidor:** <#751891992178327573>\n"+ + "**Obtén roles geniales:** <#938245623495393300>" + }, + "memberJoinLog" : { + "title" : "👋🏻 Un usuario se acaba de unir al servidor" + }, + + // ==== on:guildMemberRemove + "memberLeftLog" : { + "title" : "👋🏻 Un usuario se acaba de ir del servidor" + } +} \ No newline at end of file diff --git a/data/i18n/roles.js b/data/i18n/roles.js new file mode 100644 index 0000000..12e01ba --- /dev/null +++ b/data/i18n/roles.js @@ -0,0 +1,15 @@ +module.exports = { + "alertas" : { + "title" : "**📣 Roles de Alertas**", + "description" : "Si deseas recibir alertas específicas, haz clic en los botones de abajo para recibir el rol y estar al tanto de ello" + }, + "hobbies" : { + "title" : "**🌌 Roles de Hobbies**", + "description" : "Haz clic en los botones de abajo para recibir el rol de cada hobbie con el que te identifiques" + }, + + "colores" : { + "title" : "**🎨 Roles de Colores**", + "description" : "Haz clic en los botones de abajo para tener el rol con el color que mas te guste" + }, +} \ No newline at end of file diff --git a/data/json/i18n/tickets.json b/data/i18n/tickets.js similarity index 95% rename from data/json/i18n/tickets.json rename to data/i18n/tickets.js index 7b550e7..67d966d 100644 --- a/data/json/i18n/tickets.json +++ b/data/i18n/tickets.js @@ -1,7 +1,7 @@ -{ +module.exports = { "footer" : { "url" : "https://kuroneko.im", - "text" : "🦄 by kuroneko | Todos los derechos reservados" + "text" : "🦄 by kuroneko" }, "template" : { @@ -31,5 +31,4 @@ "description" : "Este ticket será eliminado en {seconds} segundos." } } - } \ No newline at end of file diff --git a/data/json/i18n/members.json b/data/json/i18n/members.json deleted file mode 100644 index ce79f89..0000000 --- a/data/json/i18n/members.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "memberJoinPublic" : { - "title" : "", - "description" : "" - }, - "memberJoinLog" : { - "title" : "", - "description" : "" - }, - "memberLeftPublic" : { - "title" : "", - "description" : "" - }, - "memberLeftLog" : { - "title" : "", - "description" : "" - } -} \ No newline at end of file diff --git a/ecosystem.config.js b/ecosystem.config.js index 293cc54..5400736 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -1,7 +1,7 @@ module.exports = { apps : [{ name : "TheiBot", - version : "3.1.0", + version : "3.2.0", script : "./index.js", exec_mode : "fork", diff --git a/events/members/guildMemberAdd.js b/events/members/guildMemberAdd.js index fb729bc..4cf555f 100644 --- a/events/members/guildMemberAdd.js +++ b/events/members/guildMemberAdd.js @@ -5,7 +5,8 @@ const path = require('path'); // Load configuration files ================================================================================================ const { welcomeChannel, log_JoinLeft } = require(path.resolve('./config/channels')); -const { clientId, welcomeHasImage, embedColor } = require(path.resolve('./config/bot')); +const { clientId, welcomeSendImage, welcomeSendEmbed, embedColor } = require(path.resolve('./config/bot')); +const { memberJoinPublic, memberJoinLog } = require(path.resolve('./data/i18n/members')); // Module script =========================================================================================================== module.exports = { @@ -22,8 +23,11 @@ module.exports = { sender_log.send({ embeds: [{ color: 0x89db4f, - title: `👋🏻 Un usuario se acaba de unir al servidor`, - fields: [ { name: 'Usuario', value: userTag }, { name: 'User ID', value: userId } ] + title: memberJoinLog.title, + fields: [ + { name: 'Usuario', value: userTag }, + { name: 'User ID', value: userId } + ] }] }); } catch(error) { @@ -35,8 +39,10 @@ module.exports = { try { const sender_welcome = member.guild.channels.cache.get(welcomeChannel); - let filesAttach = []; - if(welcomeHasImage) { + let attachFiles = []; + let attachEmbed = []; + + if(welcomeSendImage) { // Crear lienzo const canvas = Canvas.createCanvas(700, 250); const ctx = canvas.getContext('2d'); @@ -77,20 +83,20 @@ module.exports = { // Adjuntar contenido multimedia const mediaAttachment = new AttachmentBuilder(canvas.toBuffer(), 'img.png') - filesAttach =[ mediaAttachment ]; + attachFiles =[ mediaAttachment ]; } - sender_welcome.send({ - files: filesAttach, - embeds: [{ + if(welcomeSendEmbed) { + attachEmbed = [{ color: parseInt(embedColor, 16), - description: - `Bienvenido <@${userId}> al servidor 👋🏻 Esperamos disfrutes tu estadía en el servidor.\n\n`+ - `**Sobre Mí:** <#637941772063866890>\n`+ - `**Reglas del servidor:** <#751891992178327573>\n`+ - `**Obtén roles geniales:** <#938245623495393300>` - }] - }); + title: memberJoinPublic.title, + description: memberJoinPublic.description + }]; + } + + if(!welcomeSendImage && !welcomeSendEmbed) { return; } + + sender_welcome.send({ files: attachFiles, embeds: attachEmbed }); } catch(error) { console.error('[event:guildMemberAdd:welcome]', error.message); } diff --git a/events/members/guildMemberRemove.js b/events/members/guildMemberRemove.js index 89a31cf..1b98c00 100644 --- a/events/members/guildMemberRemove.js +++ b/events/members/guildMemberRemove.js @@ -5,6 +5,7 @@ const path = require('path'); // Load configuration files ================================================================================================ const { log_JoinLeft } = require(path.resolve('./config/channels')); const { clientId } = require(path.resolve('./config/bot')); +const { memberLeftLog } = require(path.resolve('./data/i18n/members')); // Module script =========================================================================================================== module.exports = { @@ -18,11 +19,16 @@ module.exports = { if(log_JoinLeft) { const sender_log = member.guild.channels.cache.get(log_JoinLeft); - sender_log.send({ embeds: [{ - color: 0xe35d5d, - title: `👋🏻 Un usuario se acaba de ir del servidor`, - fields: [ { name: 'Usuario', value: user }, { name: 'User ID', value: userId } ] - }] }); + sender_log.send({ + embeds: [{ + color: 0xe35d5d, + title: memberLeftLog.title, + fields: [ + { name: 'Usuario', value: user }, + { name: 'User ID', value: userId } + ] + }] + }); } } catch(error) { console.error('[event:clientMemberRemove]', error.message); diff --git a/interactions/buttons/tickets/closeTicket.js b/interactions/buttons/tickets/closeTicket.js index 9241ee7..5ed0d5f 100644 --- a/interactions/buttons/tickets/closeTicket.js +++ b/interactions/buttons/tickets/closeTicket.js @@ -5,7 +5,7 @@ const path = require('path'); // Load configuration files ================================================================================================ const { clientId } = require(path.resolve('./config/bot')); const { staffRole } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/buttons/tickets/deleteTicket.js b/interactions/buttons/tickets/deleteTicket.js index 4cdd27b..e442268 100644 --- a/interactions/buttons/tickets/deleteTicket.js +++ b/interactions/buttons/tickets/deleteTicket.js @@ -4,7 +4,7 @@ const wait = require('node:timers/promises').setTimeout; // Load configuration files ================================================================================================ const { secDelTicket } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/buttons/tickets/reopenTicket.js b/interactions/buttons/tickets/reopenTicket.js index 3755f16..19fb87b 100644 --- a/interactions/buttons/tickets/reopenTicket.js +++ b/interactions/buttons/tickets/reopenTicket.js @@ -5,7 +5,7 @@ const path = require('path'); // Load configuration files ================================================================================================ const { clientId } = require(path.resolve('./config/bot')); const { staffRole } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/selectMenu/tickets/createTicket.js b/interactions/selectMenu/tickets/createTicket.js index 44279f1..b71eca6 100644 --- a/interactions/selectMenu/tickets/createTicket.js +++ b/interactions/selectMenu/tickets/createTicket.js @@ -6,7 +6,7 @@ const wait = require('node:timers/promises').setTimeout; // Load configuration files ================================================================================================ const { clientId } = require(path.resolve('./config/bot')); const { staffRole } = require(path.resolve('./config/tickets')); -const { template, footer } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template, footer } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/slashCommands/misc/host.js b/interactions/slashCommands/misc/host.js index 56ec4b9..dcd0c16 100644 --- a/interactions/slashCommands/misc/host.js +++ b/interactions/slashCommands/misc/host.js @@ -5,7 +5,7 @@ const path = require('path'); const os = require('os'); // Load custom functions =================================================================================================== -const { footer } = require(path.resolve('./data/json/i18n/tickets.json')); +const { footer } = require(path.resolve('./data/i18n/tickets')); const helpers = require(path.resolve('./functions/helpers.js')); // Module script =========================================================================================================== diff --git a/interactions/slashCommands/misc/nuggots.js b/interactions/slashCommands/misc/nuggots.js index 3fe35b9..da0e324 100644 --- a/interactions/slashCommands/misc/nuggots.js +++ b/interactions/slashCommands/misc/nuggots.js @@ -9,7 +9,7 @@ module.exports = { .setDMPermission(false), async execute(interaction) { try { - return interaction.reply('**Nuggots for the confederation!** <:theiNuggot:1041412115728191598>'); + return interaction.reply('**Nuggots for the confederation!** 🍗'); } catch(error) { console.error('[interaction:slashcmd:nuggots]', error.message); } diff --git a/interactions/slashCommands/misc/server.js b/interactions/slashCommands/misc/server.js index 598f6e8..cf8f5bc 100644 --- a/interactions/slashCommands/misc/server.js +++ b/interactions/slashCommands/misc/server.js @@ -1,6 +1,5 @@ // Load required resources ================================================================================================= const { SlashCommandBuilder } = require('discord.js'); -const { color } = require('console-log-colors'); const path = require('path'); // Load configuration files ================================================================================================ diff --git a/interactions/slashCommands/tickets/categorias_modificar.js b/interactions/slashCommands/tickets/categorias_modificar.js index 8c26959..91921f5 100644 --- a/interactions/slashCommands/tickets/categorias_modificar.js +++ b/interactions/slashCommands/tickets/categorias_modificar.js @@ -1,6 +1,5 @@ // Load required resources ================================================================================================= const { SlashCommandBuilder } = require('discord.js'); -const { color } = require('console-log-colors'); const path = require('path'); // Load SQLite Helper ====================================================================================================== diff --git a/interactions/slashCommands/tickets/tickets_cerrar.js b/interactions/slashCommands/tickets/tickets_cerrar.js index 7ff49db..347ad74 100644 --- a/interactions/slashCommands/tickets/tickets_cerrar.js +++ b/interactions/slashCommands/tickets/tickets_cerrar.js @@ -5,7 +5,7 @@ const path = require('path'); // Load configuration files ================================================================================================ const { clientId } = require(path.resolve('./config/bot')); const { staffRole } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/slashCommands/tickets/tickets_eliminar.js b/interactions/slashCommands/tickets/tickets_eliminar.js index 3655053..c1407a5 100644 --- a/interactions/slashCommands/tickets/tickets_eliminar.js +++ b/interactions/slashCommands/tickets/tickets_eliminar.js @@ -5,7 +5,7 @@ const wait = require('node:timers/promises').setTimeout; // Load configuration files ================================================================================================ const { secDelTicket } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/interactions/slashCommands/tickets/tickets_reabrir.js b/interactions/slashCommands/tickets/tickets_reabrir.js index ac91580..16af8a5 100644 --- a/interactions/slashCommands/tickets/tickets_reabrir.js +++ b/interactions/slashCommands/tickets/tickets_reabrir.js @@ -5,7 +5,7 @@ const path = require('path'); // Load configuration files ================================================================================================ const { clientId } = require(path.resolve('./config/bot')); const { staffRole } = require(path.resolve('./config/tickets')); -const { template } = require(path.resolve('./data/json/i18n/tickets.json')); +const { template } = require(path.resolve('./data/i18n/tickets')); // Load SQLite Helper ====================================================================================================== const sqlite = require(path.resolve('./functions/tickets.js')); diff --git a/package.json b/package.json index 0ccb40e..4b94aaf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "theibot", - "version": "3.1.0", + "version": "3.2.0", "description": "Bot utilitario para Discord", "main": "index.js", "scripts": { diff --git a/to_do.md b/to_do.md deleted file mode 100644 index 9f921c3..0000000 --- a/to_do.md +++ /dev/null @@ -1,4 +0,0 @@ -### Por agregar "i18n": - -- [ ] `events/members/guildMemberAdd` -- [ ] `events/members/guildMemberRemove`