Haha-Yes/commands/minigame/borgar.js

79 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-06-17 23:03:50 +02:00
// TODO:
// Make a level system per user and increasse difficutly based on the level
// higher the level the more ingredient required
// higher the level the less time you have to complete it
const { Command } = require('discord-akairo');
const { MessageEmbed } = require('discord.js');
class borgarCommand extends Command {
constructor() {
super('borgar', {
2019-06-18 00:13:17 +02:00
aliases: ['borgar', 'hamburgor', 'hamborgar', 'burger', 'hamburger', 'borger'],
2019-06-17 23:03:50 +02:00
category: 'minigame',
args: [
{
2019-06-17 23:38:17 +02:00
id: 'ingredientNumber',
2019-06-18 01:14:36 +02:00
type: 'number',
default: 4
},
{
2019-06-17 23:38:17 +02:00
id: 'time',
2019-06-18 01:14:36 +02:00
type: 'number',
2019-06-18 00:08:07 +02:00
default: 10
}
],
2019-06-17 23:03:50 +02:00
description: {
content: 'Make amborgar,,,,,,,,,, ( MINI GAME VERY WIP, NO LEVEL YET )',
2019-06-18 00:07:12 +02:00
usage: '[number of ingredient] [time]',
2019-06-18 00:11:03 +02:00
examples: ['4 10']
2019-06-17 23:03:50 +02:00
}
});
}
async exec(message, args) {
if (args.time <= 0) args.time = 1;
2019-06-18 00:49:53 +02:00
const ingredients = [ 'bun', 'beef', 'salade', 'tomato', 'cheese', 'pickle', 'onion', 'garlic', 'basil'];
2019-06-17 23:03:50 +02:00
let hamIngredient = [];
2019-06-17 23:38:17 +02:00
for (let i = 0; i < args.ingredientNumber; i++) {
2019-06-18 00:49:53 +02:00
hamIngredient[i] = ingredients[Math.floor( Math.random() * ingredients.length )];
2019-06-17 23:03:50 +02:00
}
2019-07-11 22:09:49 +02:00
let borgarEmbed = new MessageEmbed()
2019-06-17 23:03:50 +02:00
.setTitle('hamborger delivery')
2019-06-17 23:38:17 +02:00
.setDescription(`could you do me an **amborgar** that contain **${hamIngredient}**`)
2019-07-12 05:48:49 +02:00
.setFooter(`Level 0 | Once the ingredients dissapear you have ${args.time} seconds to do it!`)
2019-06-17 23:03:50 +02:00
.setTimestamp();
2019-07-11 22:09:49 +02:00
message.util.send(borgarEmbed)
.then(() => {
setTimeout(async () => {
borgarEmbed = new MessageEmbed()
.setTitle('hamborger delivery')
.setDescription('You have to put each ingredients in seperate message!')
.setFooter(`Level 0 | you have ${args.time} seconds to make that hamborgor`)
.setTimestamp();
message.util.edit(borgarEmbed);
2019-06-17 23:03:50 +02:00
2019-07-11 22:09:49 +02:00
const filter = m => m.content && m.author.id == message.author.id;
2019-07-11 23:07:38 +02:00
message.channel.awaitMessages(filter, {time: args.time * 1000, max: hamIngredient.length, errors: ['time'] })
.then(messages => {
let userIngredient = messages.map(messages => messages.content);
2019-07-11 22:09:49 +02:00
if (userIngredient.toString().toLowerCase() == hamIngredient.toString()) {
return message.reply('u won bro,,,, that\'s kinda epic if i do say so myself');
2019-07-11 23:07:38 +02:00
} else if (userIngredient.length == hamIngredient.length) {
return message.reply(`you failed noob... you were supposed to make **${hamIngredient}**`);
} else if (userIngredient.length > hamIngredient.length) {
return message.reply('Too much ingredient...');
2019-07-11 22:09:49 +02:00
}
2019-07-11 23:07:38 +02:00
})
.catch(() => {
return message.reply('time runned out noob...');
2019-07-11 22:09:49 +02:00
});
2019-07-11 23:17:58 +02:00
}, 3000);
2019-06-17 23:03:50 +02:00
});
}
}
module.exports = borgarCommand;