Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bot.on('message', message => {
- if(message.content.startsWith("d!bingo")) {
- let limit = message.content.split(" ")[1];
- if(!limit || isNaN(limit) || limit > 500) {
- return message.channel.send("Utilisation de la commande : d!bingo [0 - 500]");
- }
- message.channel.send(`Un bingo vient de commencer ! Vous avez **1** minutes pour trouver le nombre mystère qui est compris entre **0** et **${limit}**`)
- .then(async(m) => {
- const random = Math.floor(Math.random() * limit);
- const filter = m => m.author.id !== bot.user.id;
- const collector = await m.channel.createMessageCollector(filter, { time: 60000 });
- collector.on("collect", async(collected) => {
- if(collected.content.toLowerCase() === "annuler") {
- return collector.stop(`✅ Bingo annulé !`);
- } else {
- let response = await collected.content.trim();
- response = parseInt(response);
- if(isNaN(response)) {
- return message.channel.send("Ce n'est pas un nombre !");
- }
- else if(response === random) {
- await collector.stop(`${collected.author.toString()} a remporté le Bingo, le nombre était: **${random}**`);
- }
- }
- });
- collector.on("end", async(collected, reason) => {
- if(reason && reason !== "time") {
- return message.channel.send(reason);
- } else {
- return message.channel.send(`Personne n'a remporté le Bingo, le nombre était : **${random}**`);
- }
- });
- });
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement