npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-games89

v0.0.1

Published

Discord Games package!

Downloads

3

Readme

Discord Games BETA

NOTE:

This is my first npm package, used for testing with my friends. Feel free to continue reading if you want to use it for yourself.

If you have any errors or issues, please update the package by doing npm i discord-games89 and read the contents in the usage section to make sure you have coded it correctly

What is this ?

This is a package used to enable an game event inside a Discord Voice Channel, like YouTube Watch Togther, Chess, Word Tile, and much more.

How does this work ?

This works by creating an invite to a voice channel of your will in such a way that is makes game playable in that specific voice channel.

Installation

npm i discord-games89

Usage

  • Constructor:
const DiscordGame = require('discord-games89');
const game = new DiscordGame(params);
  • Params:
/**
 * (YourDiscordBotToken, NameOfTheGame, MaximumDuration, {Options})
 */

const game = new DiscordGame('Token', 'chess', 2, {neverExpire: false});

/**
 * "Token" is the Discord Client which you are using in your code
 * "chess" is the name of the game which you wanted to play
 * "2" is the Maximum Duration of the game event in hours
 * 
 * "neverExpire" is an optional parameter by which you can choose wheater you want your invite link to get expired or not
 * Normally it will get expired after the "MaximumDuration" but by setting the parameter to true, the link will not expire on its own
 */

NOTE: The Maximum Duration can only be more than 0

  • Function:
game.play(vc).then(result => console.log(result));

// "vc" is the Discord Voice channel which you want to play the game in.
  • Result:
{
    code : String // Code of the invite link
    inviteLink : String // The invite link itself
    createdAt : Date // The time when the invite was created
    validTill : Date | String // The time at which the invite gets expired, if 'neverExpire' is set as 'true' you will get a string

    guild :
    {
        ID : String // ID of the server in which the invite has been made
        name : String // Name of the server in which the invite has been made
    },

    channel :
    {
        ID : String // ID of the channel to which the invite has been made
        name : String // Name of the channel to which the invite has been made
    },

    inviter : 
    {
        ID : String // ID of the user who made the invite (i.e, The Bot's ID which has been used to do the task)
        name : String // Name of the user who made the invite (i.e, The Bot's Name which has been used to do the task)
    },

    app :
    {
        ID : String // ID of the game
        name : String // Name of the game
        description : String // A short description of the game
        summary : String // A summary of the game
        maxMembers : String // Maximum number of members the game allows
    }
}

Example Code (for one game)

const Discord = require('discord.js');
const DiscordGame = require('discord-games89');

const client = new Discord.Client();
const YouTube = new DiscordGame('Token', 'youtube', 2);

client.on('messageCreate', (message) =>
{
    if (message.content === 'play')
    {    
        const VoiceChannel = message.member.voice.channel;  // The voice channel in which the event is gonna occur

        YouTube.play(VoiceChannel).then(result => message.channel.send(result.inviteLink));
    }
});

client.login('Token');

What should I do if I want to play other games ?

Just replace name of the game which is the second parameter of constructor (i.e, new DiscordGame()) with any of the available games

To get the list of the available games you can do

const DiscordGame = require('discord-games89');
const game = new DiscordGame();

console.log(game.gameNames()); // This will print all the available games in your console !

Output:

youtube
poker
betrayal
fishing
chess
letterLeague
wordSnack
awkword
doodleCrew
spellCast
checkers
sketchHeads
blazing8s
landIO
puttParty
bobbleLeague
askAway
kwim    // Game name for "Know What I Meme !"

Example code (for more than one games)

const Discord = require('discord.js');
const DiscordGame = require('discord-games89');

const client = new Discord.Client();

const YouTube = new DiscordGame('Token', 'youtube', 10);
const Chess = new DiscordGame('Token', 'chess', 1);
const LetterTile = new DiscordGame('Token', 'lettertile', 5);
const WordSnack = new DiscordGame('Token', 'wordsnack', 3);
const DoodleCrew = new DiscordGame('Token', 'doodlecrew', 2);

client.on('messageCreate', (message) =>
{
    if (message.content === 'play')
    {
        const games =
        [
            "🇦 - YouTube Watch Together",
            "🇧 - Chess",
            "🇨 - Letter Tile",
            "🇩 - Word Snack",
            "🇪 - Doodle Crew"
        ];

        const ReactionEmbed = new Discord.MessageEmbed()
        .setColor('#2F3136')
        .setDescription(`React to the appropriate emoji to start a game !\n\n${games.join('\n')}`);

        message.channel.send({embeds: [ReactionEmbed]}).then((msg) =>
        {
            msg.react('🇦');
            msg.react('🇧');
            msg.react('🇨');
            msg.react('🇩');
            msg.react('🇪');

            const collector = new Discord.ReactionCollector(msg);
    
            collector.on('collect', (reaction) =>
            {
                collector.stop();

                const VoiceChannel = message.member.voice.channel;  // The voice channel in which the event is gonna occur

                const data =
                {
                    "🇦" : YouTube,
                    "🇧" : Chess,
                    "🇨" : LetterTile,
                    "🇩" : WordSnack,
                    "🇪" : DoodleCrew
                };

                data[reaction.emoji.name].play(VoiceChannel).then((result) => message.channel.send(result.inviteLink));
            });
        });
    }
});

client.login('Token');

Known Issue:

Error:

\node_modules\discord-games-beta\index.js:1
const fetch = require('node-fetch');
              ^

Error [ERR_REQUIRE_ESM]: require() of ES Module ... 

Fix:

Have Fun 🥳