1.1.8 • Published 2 years ago

discord.js-games v1.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

discord.js-games

A discord.js v13 module which allows you to add minigames to your bot super easily!

Notable Features

  • Slash commands and messages support
  • Gives result of the game back
  • Promise-based
  • Customisable
  • Easy to implement
  • TypeScript support

Documentation

You can find it in the wiki section of the GitHub repository.

How to??????

Installation

npm i discord.js-games

Playing

CommonJS Example

const { GuildMember } = require('discord.js');
const { blackjack, rps } = require('discord.js-games');

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;
  
  if (interaction.commandName === 'blackjack') {
    const result = await blackjack({ message: interaction });

    console.log('user won', result);
  } else if (interaction.commandName === 'rps') {
    rps({ message: interaction });
  }
});
client.on('messageCreate', async message => {
  if (message.content === 'blackjack') {
    blackjack({ message });
  } else if (message.content === 'rps') {
    const opponent = message.mentions.members?.first();
    const result = await rps({
      message,
      ...(opponent instanceof GuildMember && { opponent })
    });

    console.log('user won', result);
  }
});

ES6/TypeScript Example

import { GuildMember } from 'discord.js';
import { blackjack, rps } from 'discord.js-games';

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;
  
  if (interaction.commandName === 'blackjack') {
    const result = await blackjack({ message: interaction });

    console.log('user won', result);
  } else if (interaction.commandName === 'rps') {
    rps({ message: interaction });
  }
});
client.on('messageCreate', async message => {
  if (message.content === 'blackjack') {
    blackjack({ message });
  } else if (message.content === 'rps') {
    const opponent = message.mentions.members?.first();
    const result = await rps({
      message,
      ...(opponent instanceof GuildMember && { opponent })
    });

    console.log('user won', result);
  }
});

Issues, bugs, questions, PRs, etc

Open up an issue for anything relating to this package, that can be bugs, issues, feature requests, etc. Same goes for pull requests, feel free to submit one for improved performance, better code practices, etc.

1.1.8

2 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago