discord-games.js
v1.0.1-beta
Published
Juegos para tu bot de Discord
Downloads
3
Readme
Discord-games.js
Instalación
npm i discord-games.js
Bingo
Uso
Aquí tienes un ejemplo básico de cómo utilizar la función Bingo:
const Discord = require('discord.js');
const { Bingo, Player } = require('discord-games.js');
const client = new Discord.Client();
const bingo = new Bingo();
const players = new Map();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('message', (message) => {
if (message.author.bot) return;
if (message.content.startsWith('!join')) {
const player = new Player(message.author.id, message.author.username);
bingo.agregarJugador(player);
players.set(message.author.id, player);
message.channel.send(`¡El jugador ${message.author.username} se ha unido al juego!`);
}
if (message.content.startsWith('!start')) {
bingo.iniciarJuego();
message.channel.send('¡El juego ha comenzado! ¡Prepárate!');
players.forEach((player) => {
player.asignarCarton(bingo.generarCarton());
const user = client.users.cache.get(player.id);
message.channel.send(`${user.username}, aquí está tu cartón:\n${player.mostrarCarton()}`);
});
}
if (message.content.startsWith('!call')) {
const calledNumber = bingo.llamarNumero();
const embed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Bingo')
.setDescription(`Número llamado: ${calledNumber}`)
.addField('Números llamados hasta ahora:', bingo.obtenerNumerosLlamados().join(', '))
.setTimestamp();
message.channel.send(embed);
players.forEach((player) => {
if (bingo.verificarGanador(player)) {
const user = client.users.cache.get(player.id);
message.channel.send(`¡El jugador ${user.username} ha dicho BINGO!`);
}
});
}
});
client.login('TU_TOKEN_DE_DISCORD');
Funciones
| Nombre | Requiere await | | --------- | --------- | | Bingo | No |