Discord Minesweeper

Create games of minesweeper using Discords Spoiler Tags.

Usage

const mines = require('discord-minesweeper');

let output = mines(X, Y, mines, char, formatted);

Parameters

ParameterDescription
XWidth
YHeight
minesNumber of mines
charCharacter to use internally to represent bombs. If formatted == false, this will be used to represent bombs in the output array.
formattedWhether to output as a formatted message (with line breaks and emojis) or as a 2D array.

Example

const Discord = require('discord.js');
const client = new Discord.Client();
const mines = require('discord-minesweeper');

...

client.on('message', msg => {
  if (msg.content === '!mines') {
    msg.author.send(mines(14, 14, 20, 'X', true));
  }
});

Browser Example

If you want to run this in the browser to create text that you can copy and paste.

Browser Example

Links

Leave a Reply

Your email address will not be published. Required fields are marked *