Haha-Yes/commands/minigame/borgar.js

116 lines
3.6 KiB
JavaScript
Raw Normal View History

2019-06-17 23:03:50 +02:00
// TODO:
2019-10-09 01:32:18 +02:00
// Higher the level the less time you have to complete it
// Make the command less shit
2019-06-17 23:03:50 +02:00
const { Command } = require('discord-akairo');
const { MessageEmbed } = require('discord.js');
2019-10-09 01:32:18 +02:00
const borgar = require('../../models').borgar;
2019-06-17 23:03:50 +02:00
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',
description: {
2019-10-09 01:36:33 +02:00
content: 'Make amborgar,,,,,,,,,, ( MINI GAME VERY WIP, LEVEL/XP SYSTEM MIGHT BE BULLSHIT )',
usage: '',
examples: ['']
2019-06-17 23:03:50 +02:00
}
});
}
2019-10-09 01:32:18 +02:00
async exec(message) {
let level;
let curxp;
let xp = Math.floor((Math.random() * 23) + 1);
const userInfo = await borgar.findOne({where: {userID:message.author.id}});
if (userInfo) {
curxp = userInfo.get('xp');
if (curxp < 100) {
level = 1;
} else if (curxp >= 100) {
level = 2;
} else if (curxp >= 200) {
level = 3;
} else if (curxp >= 300) {
level = 4;
} else if (curxp >= 400) {
level = 5;
} else if (curxp >= 500) {
level = 6;
}
} else {
curxp = 0;
level = 1;
}
2019-10-09 19:09:22 +02:00
const ingredients = ['beef', 'salad', 'tomato', 'cheese', 'pickle', 'onion', 'garlic', 'basil', 'lettuce', 'bacon'];
2019-06-17 23:03:50 +02:00
let hamIngredient = [];
2019-10-09 01:32:18 +02:00
hamIngredient.push('bun');
for (let i = 1; i < level + Math.floor(Math.random() * 2) + 1; i++) {
hamIngredient[i] = ingredients[Math.floor(Math.random() * ingredients.length)];
2019-06-17 23:03:50 +02:00
}
2019-10-09 01:32:18 +02:00
hamIngredient.push('bun');
2019-06-17 23:03:50 +02:00
2019-07-11 22:09:49 +02:00
let borgarEmbed = new MessageEmbed()
2019-10-09 01:32:18 +02:00
.setTitle('hamborger info')
2019-06-17 23:38:17 +02:00
.setDescription(`could you do me an **amborgar** that contain **${hamIngredient}**`)
2019-10-09 01:32:18 +02:00
.setFooter(`Level ${level} | Once the ingredients dissapear you have 10 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')
2019-07-23 17:14:39 +02:00
.setDescription('You have to put each ingredients in seperate messages!')
2019-10-09 01:32:18 +02:00
.setFooter(`Level ${level} | you have 10 seconds to make that hamborgor`)
2019-07-11 22:09:49 +02:00
.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-10-09 01:32:18 +02:00
message.channel.awaitMessages(filter, {time: 10 * 1000, max: hamIngredient.length, errors: ['time'] })
2019-07-11 23:07:38 +02:00
.then(messages => {
let userIngredient = messages.map(messages => messages.content);
2019-10-09 01:32:18 +02:00
let body;
if (userIngredient.toString().toLowerCase() == hamIngredient.toString().toLowerCase()) {
let totalXP = curxp + xp;
body = {userID: message.author.id, level: level, xp: totalXP};
if (curxp == 0) {
message.reply(`u won bro,,,, that's kinda epic if i do say so myself\n**you gained ${xp} xp.**`);
} else {
message.reply(`u won bro,,,, that's kinda epic if i do say so myself\n**you gained ${xp} xp. you now have ${totalXP} xp**`);
}
} else {
2019-10-09 01:34:34 +02:00
let totalXP;
if (curxp <= 0) {
2019-10-09 01:32:18 +02:00
message.reply(`you failed noob... you were supposed to make **${hamIngredient}**`);
2019-10-09 01:34:34 +02:00
totalXP = 0;
2019-10-09 01:32:18 +02:00
} else {
message.reply(`you failed noob... you were supposed to make **${hamIngredient}**\n**you lost ${xp} xp. you now have ${totalXP} xp**`);
2019-10-09 01:34:34 +02:00
totalXP = curxp - xp;
2019-10-09 01:32:18 +02:00
}
2019-10-09 01:34:34 +02:00
body = {userID: message.author.id, level: level, xp: totalXP};
2019-10-09 01:32:18 +02:00
}
2019-07-11 23:07:38 +02:00
2019-10-09 01:32:18 +02:00
if (curxp == 0) {
borgar.create(body);
} else {
borgar.update(body, {where: {userID:message.author.id}});
2019-07-11 22:09:49 +02:00
}
2019-07-11 23:07:38 +02:00
})
2019-10-09 01:32:18 +02:00
.catch(err => {
console.error(err);
return message.reply('You ran out of time 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;