@unusualabsurd/discordjs-games
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

discordjs-games

Wumpus Gaming

Create games easily from discord.js client using this package!

Requirements

+ discord.js version 13
+ node.js v16.6+

Setup basic discord.js client starter pack and the VoiceChatGame client

Full discord.js guide

const Discord = require('discord.js');
const { VoiceChatGame } = require('@unusualabsurd/discordjs-games')

const client = new Discord.Client({
    intents: 32767
})

const prefix = "YOUR_PREFIX_HERE"

client.on('ready', () => console.log(`Logged in as ${client.user.tag}`));


const vcGame = new VoiceChatGame(client);

client.on('messageCreate', async message => {
    if(message.author.bot || !message.guild || !message.content.startsWith(prefix)) return;
    
    const [cmd, ...args] = message.content.slice(prefix.length)
    .trim()
    .split(/ +/g)

    const command = cmd.toLowerCase();
    
    if(command === 'youtube') {
        // Code Here
    }
})

Creating the games

if(command === 'youtube') {
    // message.member.voice.channel = the voice channel the user is in
    vcGame.createGame(message.member.voice.channel, 'youtube')
    .then(g => message.reply(`Invite Link: ${g.invite} | Invite Code: ${g.code}`))
}

Scramble Game

const { scrambleGame } = require('@unusualabsurd/discordjs-games')

if(command === 'scramble') {
    // Time option must be a number and it is read as milliseconds
    scrambleGame(message, null, { time: 30 * 1000 })  
}

Package Sidebar

Install

npm i @unusualabsurd/discordjs-games

Weekly Downloads

2

Version

1.0.3

License

ISC

Unpacked Size

27.4 kB

Total Files

20

Last publish

Collaborators

  • unusualabsurd