1.0.1-beta • Published 3 years ago
discord-games.js v1.0.1-beta
Discord-games.js
Instalación
npm i discord-games.jsBingo
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 |
1.0.1-beta
3 years ago
1.0.0
3 years ago
1.0.26
5 years ago
1.0.25
5 years ago
1.0.24
5 years ago
1.0.23
5 years ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago