You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

disgamekit

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disgamekit - npm Package Compare versions

Comparing version

to
1.0.1

8

package.json
{
"name": "disgamekit",
"version": "1.0.0",
"version": "1.0.1",
"description": "A small package that will help making ts/js discord bot mini games way easier!",

@@ -12,3 +12,3 @@ "main": "src/index.js",

"type": "git",
"url": "git+https://github.com/Yetity/djs-game.git"
"url": "git+https://github.com/Yetity/disgamekit.git"
},

@@ -28,5 +28,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/Yetity/djs-game/issues"
"url": "https://github.com/Yetity/disgamekit/issues"
},
"homepage": "https://github.com/Yetity/djs-game#readme",
"homepage": "https://github.com/Yetity/disgamekit#readme",
"devDependencies": {

@@ -33,0 +33,0 @@ "expect.js": "^0.3.1",

@@ -1,3 +0,9 @@

# disgamekit
<h1 align="center"> disgamekit </h1>
<p align="center">
<img alt="Static Badge" src="https://img.shields.io/badge/version-1.0.1-baige">
</p>
A small package that will help making ts/js discord bot mini games way easier!
(placeholder for game example)
## Installation

@@ -298,3 +304,3 @@

// Create a game instance
const game = new Game();
const game = new Game('gameId');

@@ -361,8 +367,4 @@ // Create a plane with 5 rows and 5 columns

ActionRowBuilder,
} = require("discord.js");
const {
Game,
Plane,
PlaneObject,
} = require("disgamekit");
} = require('discord.js');
const { Game, Plane, PlaneObject } = require('disgamekit');

@@ -377,3 +379,3 @@ const client = new Client({

client.on("ready", () => {
client.on('ready', () => {
console.log(`${client.user.tag} is online`);

@@ -383,5 +385,5 @@ });

// var setup
const game = new Game(client, "game");
game.var.score = 0
const plane = new Plane(game, 10, 10, ":green_square:");
const game = new Game(client, 'game');
game.var.score = 0;
const plane = new Plane(game, 10, 10, ':green_square:');
const moveable = new PlaneObject(

@@ -391,7 +393,7 @@ plane,

3,
"moveable",
":blue_square:",
'moveable',
':blue_square:',
true
);
const nonmove = new PlaneObject(plane, 2, 2, "nonmove", ":apple:");
const nonmove = new PlaneObject(plane, 2, 2, 'nonmove', ':apple:');

@@ -401,35 +403,35 @@ // game controls

new ButtonBuilder()
.setCustomId("up")
.setLabel("up")
.setCustomId('up')
.setLabel('up')
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("down")
.setLabel("down")
.setCustomId('down')
.setLabel('down')
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("left")
.setLabel("left")
.setCustomId('left')
.setLabel('left')
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("right")
.setLabel("right")
.setCustomId('right')
.setLabel('right')
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setCustomId("end")
.setLabel("end")
.setCustomId('end')
.setLabel('end')
.setStyle(ButtonStyle.Danger)
);
client.on("messageCreate", async (m) => {
client.on('messageCreate', async (m) => {
if (m.author.bot) return;
const message = m.content;
if (!message.includes("mjb?")) return;
if (!message.includes('mjb?')) return;
let cmd = message.split("?");
let cmd = message.split('?');
switch (cmd[1]) {
case "help":
m.reply("No.");
case 'help':
m.reply('No.');
break;
case "button":
case 'button':
game.start();

@@ -440,3 +442,3 @@ plane.update(moveable, nonmove); // show the initial state by updating the object to the grid before hand

new EmbedBuilder()
.setTitle("g a m e")
.setTitle('g a m e')
.setDescription(plane.return()),

@@ -450,14 +452,20 @@ ],

// game events
game.on("start", () => {
console.log("Game started!");
game.on('start', () => {
console.log('Game started!');
});
game.on("end", async (i) => {
await i.update({ content: `game has ended! Your final score = ${game.var.score}`, components: [], embeds: [] }); // clear buttons so no errors occur.
console.log("Game ended!");
game.on('end', async (i) => {
await i.update({
content: `game has ended! Your final score = ${game.var.score}`,
components: [],
embeds: [],
}); // clear buttons so no errors occur.
console.log('Game ended!');
});
moveable.on("collision", (obj) => { // when the moveable collides with nonemoveable update the score, if wall, log it to the console.
moveable.on('collision', (obj) => {
// when the moveable collides with nonemoveable update the score, if wall, log it to the console.
if (obj.id == nonmove.id) {
game.var.score++
} else if (obj.id == "wall") { // You can just use an if since it's 2 objects but i used an else if for documentation sake
console.log("Collision with wall!")
game.var.score++;
} else if (obj.id == 'wall') {
// You can just use an if since it's 2 objects but i used an else if for documentation sake
console.log('Collision with wall!');
}

@@ -469,19 +477,19 @@ });

switch (i.customId) {
case "up":
case 'up':
moveable.y++;
await update(i, plane, moveable, nonmove);
break;
case "down":
case 'down':
moveable.y--;
await update(i, plane, moveable, nonmove);
break;
case "left":
case 'left':
moveable.x--;
await update(i, plane, moveable, nonmove);
break;
case "right":
case 'right':
moveable.x++;
await update(i, plane, moveable, nonmove);
break;
case "end":
case 'end':
game.end(i);

@@ -504,3 +512,3 @@ }

.setDescription(plane.return())
.setFooter({text: `Score = ${game.var.score}`})
.setFooter({ text: `Score = ${game.var.score}` }),
],

@@ -507,0 +515,0 @@ components: [row],