Giter Club home page Giter Club logo

playerbot's Issues

Would you rather game

Try converting this to work with lobby system.

const { MessageButton, MessageActionRow } = require("discord.js");
const fetch = require("node-fetch")


module.exports = {

    name:'wyr',
    description:'Would You Rather Game',


    async execute(message, args,client){


        try{

            const res = await fetch("http://api.xaliks.xyz/random/wyr").then((re) =>
                re.json()
            );

        

            const row = new MessageActionRow()
            .addComponents(

                new MessageButton()
                        .setCustomId('primary')
                        .setLabel(`${res.questions[0].question}`)
                        .setStyle('PRIMARY'),
                new MessageButton()
                        .setCustomId("second")
                        .setLabel(`${res.questions[1].question}`)
                        .setStyle("DANGER"),
        );

        message.channel.send({content: "Would You Rather", components:[row]})

        
        const filter = interaction => interaction.customId === 'primary' && interaction.user.id === message.author.id;
        const filter2 = interaction => interaction.customId === 'second' && interaction.user.id === message.author.id;
        const collector = message.channel.createMessageComponentCollector({ filter, time: 60000 });
        const collector2 = message.channel.createMessageComponentCollector({ filter: filter2, time: 60000 });

``
            collector.on('collect', async(ButtonInteraction) => {

                if(!ButtonInteraction.member.id === message.author.id) return interaction.reply({ content: "Only the author of the button can use this command", ephemeral: true})
                const id = ButtonInteraction.customId
                
                
                if (id === 'primary') {
                    const row2 = new MessageActionRow()
                    .addComponents(
                        new MessageButton()
                            .setCustomId('primary')
                            .setLabel(`${res.questions[0].question}: `+ " "+ `${res.questions[0].percentage}%`)
                            .setStyle('PRIMARY')
                            .setDisabled(),
                    new MessageButton()
                            .setCustomId("second")
                            .setLabel(`${res.questions[1].question}: `+ " "+ `${res.questions[1].percentage}%`)
                            .setStyle("SECONDARY")
                            .setDisabled(),
                    );

                    await ButtonInteraction.update({ content: `**Would You Rather**`, components: [row2] });
                }
                    
                
            })

            collector2.on('collect', async(ButtonInteraction) => {

                if(!ButtonInteraction.member.id === message.author.id) return interaction.reply({ content: "Only the author of the button can use this command", ephemeral: true})
                const id = ButtonInteraction.customId

                if (id === 'second') {
                    const row2 = new MessageActionRow()
                    .addComponents(
                        new MessageButton()
                            .setCustomId('primary')
                            .setLabel(`${res.questions[0].question}: `+ " "+ `${res.questions[0].percentage}%`)
                            .setStyle('SECONDARY')
                            .setDisabled(),
                    new MessageButton()
                            .setCustomId("second")
                            .setLabel(`${res.questions[1].question}: `+ " "+ `${res.questions[1].question}%`)
                            .setStyle("DANGER")
                            .setDisabled(),
                    );
                    await ButtonInteraction.update({ content: `**Would You Rather**`, components: [row2] });
                }
            });``

        } catch(err){
            message.channel.send('API Timed Out');
        }



    }





}

Typing racing game

Will have to generate images/use fancy font to prevent copy and paste cheating

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.