Discord.js | Bot Oyunları, XOX Kodlaması

Katılım
10 Kas 2019
Konular
225
Mesajlar
1,057
Çözümler
19
Tepki puanı
1,050
Puanları
8,710
dLYznD.png

Merhaba şehrin sakinleri,
Bu konumda sizlere arkadaşlarınız ile eğlenebileceğiniz bir komut vereceğim. Xox oyununu bir çoğunuz biliyordur.
Yapmanız gereken tek şey aşağıda vermiş olduğum kodlamayı komutlar bölümüne atmak.



Biz oynarken çok eğlendik.

1611947201945.png


Kodlama;
JavaScript:
const Discord = require('discord.js');
const { randomRange, verify } = require('../util/Util');
const { stripIndents } = require('common-tags');

exports.run = async (client, msg, args) => {

  this.games = new Set();
 
    this.verifyWin = (sides) => {
        return (sides[0] === sides[1] && sides[0] === sides[2])
            || (sides[0] === sides[3] && sides[0] === sides[6])
            || (sides[3] === sides[4] && sides[3] === sides[5])
            || (sides[1] === sides[4] && sides[1] === sides[7])
            || (sides[6] === sides[7] && sides[6] === sides[8])
            || (sides[2] === sides[5] && sides[2] === sides[8])
            || (sides[0] === sides[4] && sides[0] === sides[8])
            || (sides[2] === sides[4] && sides[2] === sides[6]);
  }
    
  const opponent = msg.mentions.users.first()
  if (!opponent) return msg.reply('Bir kullanıcı girmelisiniz!')
  if (opponent.bot) return msg.reply('Botlar ile oyun oynyamazsınız.');
        if (opponent.id === msg.author.id) return msg.reply('Kendiniz ile oyun oynayamazsınız.');
        if (this.games.has(msg.channel.id)) return msg.reply('Kanal başına sadece bir düello meydana gelebilir.');
        this.games.add(msg.channel.id);
        try {
            await msg.channel.send(`${opponent}, düelloyu kabul ediyor musun?`);
            const verification = await verify(msg.channel, opponent);
            if (!verification) {
                this.games.delete(msg.channel.id);
                return msg.channel.send('Görünüşe göre kabul edilemedi!');
            }
            const sides = ['0', '1', '2', '3', '4', '5', '6', '7', '8'];
            const taken = [];
            let userTurn = true;
            let winner = null;
            while (!winner && taken.length < 9) {
                const user = userTurn ? msg.author : opponent;
                const sign = userTurn ? '𝗫' : '𝗢';
                await msg.channel.send(stripIndents`
                    ${user}, hangi tarafı almak istersin?
                    \`\`\`
                    ${sides[0]} | ${sides[1]} | ${sides[2]}
                    —————————
                    ${sides[3]} | ${sides[4]} | ${sides[5]}
                    —————————
                    ${sides[6]} | ${sides[7]} | ${sides[8]}
                    \`\`\`
                `);
                const filter = res => {
                    const choice = res.content;
                    return res.author.id === user.id && sides.includes(choice) && !taken.includes(choice);
                };
                const turn = await msg.channel.awaitMessages(filter, {
                    max: 1,
                    time: 30000
                });
                if (!turn.size) {
                    await msg.channel.send('Üzgünüm, zaman doldu!');
                    userTurn = !userTurn;
                    continue;
                }
                const choice = turn.first().content;
                sides[Number.parseInt(choice, 10)] = sign;
                taken.push(choice);
                if (this.verifyWin(sides)) winner = userTurn ? msg.author : opponent;
                userTurn = !userTurn;
            }
            this.games.delete(msg.channel.id);
            return msg.channel.send(winner ? `Tebrikler, ${winner}!` : 'Oh... Hiçkimse kazanamadı.');
        } catch (err) {
            this.games.delete(msg.channel.id);
            throw err;
        }
    }


exports.conf = {
    enabled: false,
    guildOnly: false,
    aliases: [],
    permLevel: 0
}

exports.help = {
    name: 'xox',
    description: 'xox oyunu',
    usage: 'xox oyunu'
}
 
  • Beğen
Tepkiler: Rospia ve BabaYaga
Katılım
13 Kas 2019
Konular
41
Mesajlar
398
Tepki puanı
291
Puanları
3,310
Xox oyunu kısa süren bir oyun da olsa çok rekabetli bir oyun ve zekanızın konuştuğu bir oyun, güzel bir kodlama olmuş bunun taş kağıt makas oyunu da gelir mi?
 
  • Beğen
Tepkiler: ZussaDM
Katılım
18 Kas 2020
Konular
35
Mesajlar
536
Çözümler
1
Tepki puanı
262
Puanları
3,460
Eğlenceli olacak desene:sneaky:
 
Katılım
9 Şub 2021
Konular
0
Mesajlar
1
Tepki puanı
1
Puanları
55
Ekli dosyayı görüntüle 3801
Merhaba şehrin sakinleri,
Bu konumda sizlere arkadaşlarınız ile eğlenebileceğiniz bir komut vereceğim. Xox oyununu bir çoğunuz biliyordur.
Yapmanız gereken tek şey aşağıda vermiş olduğum kodlamayı komutlar bölümüne atmak.



Biz oynarken çok eğlendik.

Ekli dosyayı görüntüle 3802

Kodlama;
JavaScript:
const Discord = require('discord.js');
const { randomRange, verify } = require('../util/Util');
const { stripIndents } = require('common-tags');

exports.run = async (client, msg, args) => {

  this.games = new Set();

    this.verifyWin = (sides) => {
        return (sides[0] === sides[1] && sides[0] === sides[2])
            || (sides[0] === sides[3] && sides[0] === sides[6])
            || (sides[3] === sides[4] && sides[3] === sides[5])
            || (sides[1] === sides[4] && sides[1] === sides[7])
            || (sides[6] === sides[7] && sides[6] === sides[8])
            || (sides[2] === sides[5] && sides[2] === sides[8])
            || (sides[0] === sides[4] && sides[0] === sides[8])
            || (sides[2] === sides[4] && sides[2] === sides[6]);
  }
   
  const opponent = msg.mentions.users.first()
  if (!opponent) return msg.reply('Bir kullanıcı girmelisiniz!')
  if (opponent.bot) return msg.reply('Botlar ile oyun oynyamazsınız.');
        if (opponent.id === msg.author.id) return msg.reply('Kendiniz ile oyun oynayamazsınız.');
        if (this.games.has(msg.channel.id)) return msg.reply('Kanal başına sadece bir düello meydana gelebilir.');
        this.games.add(msg.channel.id);
        try {
            await msg.channel.send(`${opponent}, düelloyu kabul ediyor musun?`);
            const verification = await verify(msg.channel, opponent);
            if (!verification) {
                this.games.delete(msg.channel.id);
                return msg.channel.send('Görünüşe göre kabul edilemedi!');
            }
            const sides = ['0', '1', '2', '3', '4', '5', '6', '7', '8'];
            const taken = [];
            let userTurn = true;
            let winner = null;
            while (!winner && taken.length < 9) {
                const user = userTurn ? msg.author : opponent;
                const sign = userTurn ? '𝗫' : '𝗢';
                await msg.channel.send(stripIndents`
                    ${user}, hangi tarafı almak istersin?
                    \`\`\`
                    ${sides[0]} | ${sides[1]} | ${sides[2]}
                    —————————
                    ${sides[3]} | ${sides[4]} | ${sides[5]}
                    —————————
                    ${sides[6]} | ${sides[7]} | ${sides[8]}
                    \`\`\`
                `);
                const filter = res => {
                    const choice = res.content;
                    return res.author.id === user.id && sides.includes(choice) && !taken.includes(choice);
                };
                const turn = await msg.channel.awaitMessages(filter, {
                    max: 1,
                    time: 30000
                });
                if (!turn.size) {
                    await msg.channel.send('Üzgünüm, zaman doldu!');
                    userTurn = !userTurn;
                    continue;
                }
                const choice = turn.first().content;
                sides[Number.parseInt(choice, 10)] = sign;
                taken.push(choice);
                if (this.verifyWin(sides)) winner = userTurn ? msg.author : opponent;
                userTurn = !userTurn;
            }
            this.games.delete(msg.channel.id);
            return msg.channel.send(winner ? `Tebrikler, ${winner}!` : 'Oh... Hiçkimse kazanamadı.');
        } catch (err) {
            this.games.delete(msg.channel.id);
            throw err;
        }
    }


exports.conf = {
    enabled: false,
    guildOnly: false,
    aliases: [],
    permLevel: 0
}

exports.help = {
    name: 'xox',
    description: 'xox oyunu',
    usage: 'xox oyunu'
}
hocam olmuyor cevap vermiyor prefixle denedim
 
  • Beğen
Tepkiler: MDFS
Katılım
30 Ara 2020
Konular
0
Mesajlar
10
Tepki puanı
1
Puanları
710
düelloyu kabul ediyormusun dedikten sonra evet yazınca hata veriyor hata bu (node:8822) UnhandledPromiseRejectionWarning: TypeError: verify is not a function