Skip to content

Commit

Permalink
Añadido game dice.js
Browse files Browse the repository at this point in the history
  • Loading branch information
arannnn7808 committed Jul 25, 2024
1 parent 301373a commit 9aba866
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 3 deletions.
7 changes: 5 additions & 2 deletions commands/api/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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();

Expand Down
40 changes: 40 additions & 0 deletions commands/games/dice.js
Original file line number Diff line number Diff line change
@@ -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);
}
},
};
2 changes: 1 addition & 1 deletion config/CONSTANTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added images/dices/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dices/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dices/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dices/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dices/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dices/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9aba866

Please sign in to comment.