- !Edip#0170
- Katılım
- 1 Eyl 2021
- Mesajlar
- 170
- Tepkime puanı
- 106
- Şehir
- İzmir
Merhaba.
Ekte bıraktığım adam asmaca komutunu olduğu gibi kullanmayınız.
Kendi botunuza göre kodlamayı (özellikle açıklama kısımlarını) yapmazsanız hata alırsınız.
Oyun emojilerle oynanmaktadır.
Ekte bıraktığım adam asmaca komutunu olduğu gibi kullanmayınız.
Kendi botunuza göre kodlamayı (özellikle açıklama kısımlarını) yapmazsanız hata alırsınız.
Oyun emojilerle oynanmaktadır.
JavaScript:
const Discord = require('discord.js');
const { MessageEmbed } = require("discord.js");
const config = require(`${process.cwd()}/botconfig/config.json`);
var ee = require(`${process.cwd()}/botconfig/embed.json`);
const letterEmojisMap = {
"🅰️": "A", "🇦": "A", "🅱️": "B", "🇧": "B", "🇨": "C", "🇩": "D", "🇪": "E",
"🇫": "F", "🇬": "G", "🇭": "H", "ℹ️": "I", "🇮": "I", "🇯": "J", "🇰": "K", "🇱": "L",
"Ⓜ️": "M", "🇲": "M", "🇳": "N", "🅾️": "O", "⭕": "O", "🇴": "O", "🅿️": "P",
"🇵": "P", "🇶": "Q", "🇷": "R", "🇸": "S", "🇹": "T", "🇺": "U", "🇻": "V", "🇼": "W",
"✖️": "X", "❎": "X", "❌": "X", "🇽": "X", "🇾": "Y", "💤": "Z", "🇿": "Z"
}
class HangmanGame {
constructor() {
this.gameEmbed = null;
this.inGame = false;
this.word = "";
this.guesssed = [];
this.wrongs = 0;
}
newGame(msg) {
if (this.inGame)
return;
let {client} = msg;
let es = client.settings.get(msg.guild.id, "embed");let ls = client.settings.get(msg.guild.id, "language")
this.inGame = true;
const possible_words = eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable4"])
this.word = possible_words[Math.floor(Math.random() * possible_words.length)].toUpperCase();
this.guesssed = [];
this.wrongs = 0;
const embed = new Discord.MessageEmbed()
.setColor("#2f3136")
.setAuthor('Hangman Minigame', "https://imgur.com/0guxxtY.png", "https://discord.gg/7f2QNb3ehg")
.setDescription(this.getDescription())
.addField(eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variablex_1"]), eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable1"]))
.addField(eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable6"]), eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variablex_6"]))
console.log("\n\n\n\n\n\n\n\n\n\nNEW HANGMAN GAME\n\n"+this.word+"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
msg.channel.send({embeds: [embed]}).then(emsg => {
this.gameEmbed = emsg;
this.waitForReaction();
});
}
makeGuess(reaction) {
let {client} = this.gameEmbed;
let es = client.settings.get(this.gameEmbed.guild.id, "embed");let ls = client.settings.get(this.gameEmbed.guild.id, "language")
if (Object.keys(letterEmojisMap).includes(reaction)) {
const letter = letterEmojisMap[reaction];
if (!this.guesssed.includes(letter)) {
this.guesssed.push(letter);
if (this.word.indexOf(letter) == -1) {
this.wrongs++;
if (this.wrongs == 6) {
this.gameOver(false);
}
}
else if (!this.word.split("").map(l => this.guesssed.includes(l) ? l : "_").includes("_")) {
this.gameOver(true);
}
}
}
if (this.inGame) {
const editEmbed = new Discord.MessageEmbed()
.setColor("#2f3136")
.setTitle(eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable2"]))
.setDescription(this.getDescription())
.addField('Letters Guessed', this.guesssed.length == 0 ? '\u200b' : this.guesssed.join(" "))
.addField(eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable6"]), eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variablex_6"]))
this.gameEmbed.edit({embeds: [editEmbed]});
this.waitForReaction();
}
}
gameOver(win) {
let {client} = this.gameEmbed;
let es = client.settings.get(this.gameEmbed.guild.id, "embed");let ls = client.settings.get(this.gameEmbed.guild.id, "language")
this.inGame = false;
const editEmbed = new Discord.MessageEmbed()
.setColor('RED')
.setAuthor('Hangman Minigame', "https://imgur.com/0guxxtY.png", "https://discord.gg/7f2QNb3ehg")
.setDescription(win ? eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable5"]) : eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variablex_5"]))
.addField(eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variablex_3"]),eval(client.la[ls]["cmds"]["minigames"]["hangman"]["variable3"]))
this.gameEmbed.edit({embeds: [editEmbed]});
this.gameEmbed.reactions.removeAll();
}
getDescription() {
return "```"
+ "|‾‾‾‾‾‾| \n| "
+ (this.wrongs > 0 ? "🎩" : " ")
+ " \n| "
+ (this.wrongs > 1 ? "😟" : " ")
+ " \n| "
+ (this.wrongs > 2 ? "👕" : " ")
+ " \n| "
+ (this.wrongs > 3 ? "🩳" : " ")
+ " \n| "
+ (this.wrongs > 4 ? "👞👞" : " ")
+ " \n| \n|__________\n\n"
+ this.word.split("").map(l => this.guesssed.includes(l) ? l : "_").join(" ")
+ "```";
}
waitForReaction() {
let {client} = this.gameEmbed;
let es = client.settings.get(this.gameEmbed.guild.id, "embed");let ls = client.settings.get(this.gameEmbed.guild.id, "language")
this.gameEmbed.awaitReactions({filter: () => true, max: 1, time: 300000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
this.makeGuess(reaction.emoji?.name);
reaction.remove();
})
.catch(collected => {
this.gameOver(false);
});
}
}
module.exports = {
name: "hangman",
aliases: ["hm"],
category: "🎮 MiniGames",
description: "Allows you to play a Game of Hangman",
usage: "hangman --> Play the Game",
type: "text",
run: async (client, message, args, cmduser, text, prefix) => {
let es = client.settings.get(message.guild.id, "embed");let ls = client.settings.get(message.guild.id, "language")
if(!client.settings.get(message.guild.id, "MINIGAMES")){
return message.reply({embeds: [new MessageEmbed()
.setColor(es.wrongcolor)
.setFooter(client.getFooter(es))
.setTitle(client.la[ls].common.disabled.title)
.setDescription(require(`${process.cwd()}/handlers/functions`).handlemsg(client.la[ls].common.disabled.description, {prefix: prefix}))
]});
}
new HangmanGame(client).newGame(message);
}
}