Coder Social home page Coder Social logo

falcao-g / falgames Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 450 KB

Falgames is a powerful npm package designed to help others create awesome discord bots

Home Page: https://www.npmjs.com/package/falgames

License: MIT License

JavaScript 100.00%
discord-bot discord-game discord-js discord-lib library minigames

falgames's Introduction

FALGAMES

Falgames is a helpful package to enhance your discord bot with fun and interactive minigames :)

npm version npm downloads Support server Stars

✨ Why Falgames?

  • Easy to use & beginner friendly.
  • Supports both message and slash commands.
  • Customizable to fit your bot's style.
  • 18 different minigames to choose from.

⚙️ Installation

Please note that Node v18+ and Discord.js v14+ is required.

npm i falgames

📷 Preview

Preview

📚 Usage

Starting a game with Falgames is as easy as the following example:

const { Snake } = require('falgames');

const Game = new Snake({
  message: message,
  isSlashGame: false,
  embed: {
    title: 'Snake Game',
    overTitle: 'Game Over',
    scoreText: '**Score:**',
    color: '#551476'
  },
  emojis: {
    board: '⬛',
    up: '⬆️', 
    down: '⬇️',
    left: '⬅️',
    right: '➡️',
  },
  snake: { head: '🟢', body: '🟩', tail: '🟢', over: '💀' },
  foods: ['🍎', '🍇', '🍊', '🫐', '🥕', '🥝', '🌽'],
  stopButton: 'Stop',
  timeoutTime: 60000,
  playerOnlyMessage: 'Only {player} can use these buttons.'
});

Game.startGame();
Game.on('gameOver', result => {
  console.log(result);  // =>  { result... }
});

Slash commands are also supported, just set the isSlashGame option to true and the message option to interaction:

const { Snake } = require('falgames');

const Game = new Snake({
  message: interaction,
  isSlashGame: true,
  //...
});

Make sure to check out the examples folder for more examples.

📜 Credits

This package is directed inspired by the Gamecord package.

falgames's People

Contributors

falcao-g avatar vinicius-marques6 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

falgames's Issues

Json source for Would you rather

Description

Here a json source for restoring the Would you rather game:
https://github.com/itsbrunodev/party-game-sentences/blob/master/src/json/would-you-rather.json

Possible implementation

/*/* async getWyrQuestion() {
    return await fetch('https://api.aniket091.xyz/wyr').then(res => res.json()).then(res => res?.data).catch(e => { return {} });
  }*/


  async startGame() {
    if (this.options.isSlashGame || !this.message.author) {
      if (!this.message.deferred) await this.message.deferReply().catch(e => {});
      this.message.author = this.message.user;
      this.options.isSlashGame = true;
    }
    const questionDB = JSON.parse(await (fs.readFileSync(path.join(__dirname,"would-you-rather.json"), "utf-8")));
    const question_number = Math.floor(Math.random() * questionDB.length)
    this.data = {option1 :questionDB[question_number][0], option2: questionDB[question_number][1]}
   // this.data = await this.getWyrQuestion();
   // if (!this.data.title) return this.sendMessage({ content: this.options.errMessage });


    const embed = new EmbedBuilder()
    .setColor(this.options.embed.color)
    .setTitle(this.options.embed.title)
    .setDescription(`1. ${this.data.option1} \n2. ${this.data.option2}`)
    .setAuthor({ name: this.message.author.tag, iconURL: this.message.author.displayAvatarURL({ dynamic: true }) })
    //.addFields({ name: 'Details', value: `**Title:** ${this.data.title}\n**Author:** ${this.data.author}` })


   /* const btn1 = new ButtonBuilder().setStyle(this.options.buttonStyle).setLabel(this.options.buttons.option1).setCustomId('wyr_1').setEmoji('1️⃣');
    const btn2 = new ButtonBuilder().setStyle(this.options.buttonStyle).setLabel(this.options.buttons.option2).setCustomId('wyr_2').setEmoji('2️⃣');*/
    const btn1 = new ButtonBuilder().setStyle(this.options.buttonStyle).setCustomId('wyr_1').setEmoji('1️⃣');
    const btn2 = new ButtonBuilder().setStyle(this.options.buttonStyle).setCustomId('wyr_2').setEmoji('2️⃣');

2048 doest work

Description of the bug

The code cant find the images.
It need a small fix:

const imagePath = path.join(__dirname, "..", `images/${imageFilenames[i]}`)

Steps to reproduce

Start the 2048 game

Media, if necessary

No response

Match pairs never timeout

Description of the bug

There is a small error which cause the Matchpairs game to never time. Here the fix:

const collector = msg.createMessageComponentCollector({ idle: this.options.timeoutTime});

Steps to reproduce

Start the Matchpairs game and wait. It wont timeout.

Media, if necessary

No response

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.