Kod Modülsüz Adam Asmaca Komutu

!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.

Ekran Resmi 2022-04-14 13.54.58.png
Ekran Resmi 2022-04-14 13.55.08.png



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);
    }
  }
 
  • Beğen
Tepkiler: Piques ve Calpim
Calpim#0008
Katılım
4 Mar 2022
Mesajlar
1,723
Tepkime puanı
451
Şehir
Yurtdışı
Yararlı konu, paylaşım için teşekkürler.🤖
 
  • Beğen
Tepkiler: Edip

Aventia

Aventia | Yasin
Moderator
aventia
Katılım
11 Kas 2021
Mesajlar
3,692
Tepkime puanı
1,048
Şehir
Samsun
Wow, gerçekten çok hoş gözüküyor. Emojilerle oynanması güzel olmuş. Eline sağlık. :bot_developer:
 
  • Beğen
Tepkiler: Edip
Pyderall#6509
Katılım
22 Eyl 2021
Mesajlar
34
Tepkime puanı
11
Şehir
Yurtdışı
Bunu bir süredir arıyordum. Teşekkürler. :3
 
  • Beğen
Tepkiler: Edip
Piques#5792
Katılım
17 Şub 2022
Mesajlar
269
Tepkime puanı
96
Şehir
Konya
Eline sağlık. Kendi sunucumda da kullanacağım :p
 
  • Beğen
Tepkiler: Edip
éwing#7777
Katılım
1 Eyl 2021
Mesajlar
210
Tepkime puanı
59
Ş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.

Ekli dosyayı görüntüle 2687 Ekli dosyayı görüntüle 2688



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);
    }
  }
akılmdan bu geçmişti ama önce yapmışsın başarılı :) iyi forumlar
 
4wuqey#0001
Katılım
25 Tem 2021
Mesajlar
847
Tepkime puanı
402
Şehir
Antalya
Elinize sağlık! Mükemmel görünüyor...
 

Konuyu 1 kişi okuyor. (0 kayıtlı üye ve 1 ziyaretçi)

Benzer konular

  • Bilgi