# discord.js-games

> A discord.js v13 module for minigames

Latest version **1.1.8** (published 2022-06-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install discord.js-games
pnpm add discord.js-games
yarn add discord.js-games
bun add discord.js-games
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2022-06-09 |
| First published | 2021-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.6.0 |
| Dependencies | 2 |
| Unpacked size | 58.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | CarelessInternet |
| Maintainers | carelessinternet |
| Keywords | discord.js, games, minigames, nodejs, fun |

## Links

- npm: https://www.npmjs.com/package/discord.js-games
- Repository: https://github.com/CarelessInternet/discord.js-games
- Homepage: https://github.com/CarelessInternet/discord.js-games#readme
- Issues: https://github.com/CarelessInternet/discord.js-games/issues
- npm.io page: https://npm.io/package/discord.js-games

## Dependencies (2)

- [discord.js](https://npm.io/package/discord.js.md) ^13.8.0
- [@discordjs/builders](https://npm.io/package/@discordjs/builders.md) ^0.15.0

## Recent versions

- 1.1.8 (latest) — 2022-06-09
- 1.1.7 — 2022-05-17
- 1.1.6 — 2022-04-20
- 1.1.5 — 2022-01-26
- 1.1.4 — 2022-01-19
- 1.1.3 — 2022-01-12
- 1.1.2 — 2021-12-29
- 1.1.1 — 2021-12-29
- 1.1.0 — 2021-12-02
- 1.0.2 — 2021-11-16
- 1.0.1 — 2021-11-15
- 1.0.0 — 2021-11-15

## README

<div align="center">
  <img src="https://img.shields.io/npm/dw/discord.js-games">
  <img src="https://img.shields.io/npm/l/discord.js-games">
  <img src="https://img.shields.io/node/v/discord.js-games?color=yellow">
  <img src="https://img.shields.io/npm/v/discord.js-games">
  <img src="https://img.shields.io/github/commit-activity/m/CarelessInternet/discord.js-games?color=purple">
</div>

# 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](https://github.com/CarelessInternet/discord.js-games/wiki) of the [GitHub repository](https://github.com/CarelessInternet/discord.js-games).

## How to??????

### Installation

```
npm i discord.js-games
```

### Playing

#### CommonJS Example
```js
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
```ts
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.

---
_Source: https://npm.io/package/discord.js-games · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
