diff --git a/commands/api/translate.js b/commands/api/translate.js index 43c3ffc..ef279a1 100644 --- a/commands/api/translate.js +++ b/commands/api/translate.js @@ -46,7 +46,9 @@ module.exports = { cooldown: 5, async execute(interaction) { try { + const { franc } = await import('franc'); const textoATraducir = interaction.options.getString("texto"); + const idiomaOrigen = franc(textoATraducir); const idiomaDestino = interaction.options.getString("idioma"); logger.info("Starting translation", { @@ -58,13 +60,14 @@ module.exports = { const resultado = await translate(textoATraducir, { to: idiomaDestino }); const idiomaDetectado = resultado.raw.src; - const banderaDestino = banderas[idiomaDestino] || "🏳️"; + const banderaOrigen = banderas[idiomaOrigen] || "🏳️"; + const banderaDestino = banderas[idiomaDestino] || '🏳️'; const embed = new CustomEmbedBuilder() .setTitle("🌐 Traducción") .addField("📝 Texto original", textoATraducir) .addField("🔄 Traducción", `${banderaDestino} ${resultado.text}`) - .addField("🌍 Idiomas", `De: ${idiomaDetectado} → A: ${idiomaDestino}`) + .addField("🌍 Idiomas", `De: (${banderaOrigen}) ${idiomaDetectado} → A: (${banderaDestino}) ${idiomaDestino}`) .setFooter({ text: "Traducción realizada con éxito" }) .build(); diff --git a/commands/games/dice.js b/commands/games/dice.js new file mode 100644 index 0000000..5006fd4 --- /dev/null +++ b/commands/games/dice.js @@ -0,0 +1,40 @@ +const { SlashCommandBuilder, AttachmentBuilder } = require("discord.js"); +const { EmbedBuilder } = require("discord.js"); +const logger = require("../../utils/logger"); +const ErrorHandler = require("../../utils/errorHandler"); +const fs = require('fs'); +const path = require('path'); + +module.exports = { + data: new SlashCommandBuilder() + .setName("dado") + .setDescription("Tira un dado y sale un numero al azar del 1-6"), + folder: "games", + cooldown: 3, + async execute(interaction) { + try { + const roll = Math.floor(Math.random() * 6) + 1; + const imagePath = path.join(__dirname, '..', '..', 'images', 'dices', `${roll}.png`); + + if (!fs.existsSync(imagePath)) { + throw new Error(`Image not found: ${imagePath}`); + } + + const attachment = new AttachmentBuilder(imagePath, { name: `${roll}.png` }); + + const embed = new EmbedBuilder() + .setTitle('Dados') + .setDescription(`Has tirado un dado de 6 caras`) + .addFields({ name: 'Respuesta:', value: `🎲 ${roll}`, inline: true }) + .setColor("#FFA500") + .setThumbnail(`attachment://${roll}.png`); + + await interaction.editReply({ embeds: [embed], files: [attachment] }); + logger.info(`Roll command executed by ${interaction.user.tag}`, { + result: roll + }); + } catch (error) { + await ErrorHandler.handle(error, interaction); + } + }, +}; \ No newline at end of file diff --git a/config/CONSTANTS.js b/config/CONSTANTS.js index af63425..8282213 100644 --- a/config/CONSTANTS.js +++ b/config/CONSTANTS.js @@ -2,7 +2,7 @@ module.exports = { DEFAULT_COLOR: "#0099ff", ERROR_COLOR: "#FF0000", SUCCESS_COLOR: "#00FF00", - COMMAND_FOLDERS: ["moderation", "utility", "api"], + COMMAND_FOLDERS: ["moderation", "utility", "api", "games"], DEFAULT_COOLDOWN: 3, // Default cooldown in seconds COMMAND_COOLDOWNS: { ban: 10, diff --git a/images/dices/1.png b/images/dices/1.png new file mode 100644 index 0000000..6b03647 Binary files /dev/null and b/images/dices/1.png differ diff --git a/images/dices/2.png b/images/dices/2.png new file mode 100644 index 0000000..1ea825a Binary files /dev/null and b/images/dices/2.png differ diff --git a/images/dices/3.png b/images/dices/3.png new file mode 100644 index 0000000..d372143 Binary files /dev/null and b/images/dices/3.png differ diff --git a/images/dices/4.png b/images/dices/4.png new file mode 100644 index 0000000..9b7bfe9 Binary files /dev/null and b/images/dices/4.png differ diff --git a/images/dices/5.png b/images/dices/5.png new file mode 100644 index 0000000..20abbc1 Binary files /dev/null and b/images/dices/5.png differ diff --git a/images/dices/6.png b/images/dices/6.png new file mode 100644 index 0000000..a5352e3 Binary files /dev/null and b/images/dices/6.png differ