diff --git a/nodejs/controller/commands/fun.js b/nodejs/controller/commands/fun.js index 5d804c4..eb43fde 100644 --- a/nodejs/controller/commands/fun.js +++ b/nodejs/controller/commands/fun.js @@ -1,3 +1,8 @@ +'use strict'; + +const axios = require('axios'); + + let ballOptions = [ "It is certain.", "It is decidedly so.", @@ -34,41 +39,100 @@ module.exports = { `> ${ballOptions[Math.floor(Math.random()*ballOptions.length)]}` ); } - } + }, + "joke": { + desc: "Tells a random joke.", + async function(from){ + await this.say('> Let me think...'); + let res = await axios.get('https://v2.jokeapi.dev/joke/Any?type=single') + await this.say(...res.data.joke.split('\n').map(e => `> ${e}`)); + }, + }, + "quote": { + desc: 'Say an inspirational quote.', + async function(from){ + await this.say('> Right away!'); + let res = await axios.get('https://zenquotes.io/api/random') + await this.say(`> ${res.data[0].q} -- ${res.data[0].a}`); + } + }, + 'west-quote': { + desc: `Say a random Kanye West quote.`, + async function(from) { + await this.say('> And here we go!'); + let res = await axios.get('https://api.kanye.rest/'); + await this.say(`> ${res.data.quote} -- Kanye West`); + } + }, + "fact": { + desc: `Say a random fact.`, + async function(from){ + await this.say('> The internet says this is true?'); + let res = await axios.get('https://uselessfacts.jsph.pl/random.json?language=en') + await this.say( + `> ${res.data.text}`, + `> source: ${res.data.source}` + ); + } + }, + "advice": { + desc: `Say some random advice.`, + async function(from){ + await this.say('> Try this:'); + let res = await axios.get('https://api.adviceslip.com/advice'); + await this.say(`> ${res.data.slip.advice}`); + } + }, + 'idea': { + desc: `Say a random start up idea.`, + async function(from){ + await this.say('> How about?'); + let res = await axios.get('https://itsthisforthis.com/api.php?text') + await this.say(`> ${res.data}`); + } + }, + 'discord': { + desc: `Say the CJ discord invite link.`, + async function(from) { + await this.say('https://discord.gg/hyby9m8'); + } + }, + 'dice': { + desc: `Roll a die. You can state the max size on the dice. Default is 6.`, + async function(from, size){ + size = size || 6; + if(!Number.isInteger(Number(size))){ + this.whisper(from, `${size} is not a whole number...`) + return ; + } + await this.say( + `> Rolling a dice for ${from}`, + `> ${Math.floor(Math.random()*size)+1}` + ); + } + }, + 'flip': { + desc: `Flip a coin.`, + async function(from){ + await this.say( + `> Flipping a coin for ${from}`, + `> ${!!(Math.floor(Math.random() * (3000 - 1500) + 1500)%2) ? "Heads" : "Tails"}` + ); + } + }, + 'random-player': { + desc: `Return a random online player.`, + async function(from){ + let players = bot.getPlayers() + + delete players[bot.bot.entity.username] + let keys = Object.keys(players); + let player = players[keys[ keys.length * Math.random() << 0]]; - - - - - - -// bot.addCommand("joke", { -// desc: "Tells a random joke.", -// async function(from){ -// await this.say('> Let me think...'); -// let res = await axios.get('https://v2.jokeapi.dev/joke/Any?type=single') -// await this.say(...res.data.joke.split('\n').map(e => `> ${e}`)); -// }, -// }); - -// bot.addCommand("quote", { -// desc: 'Say an inspirational quote.', -// async function(from){ -// await this.say('> Right away!'); -// let res = await axios.get('https://zenquotes.io/api/random') -// await this.say(`> ${res.data[0].q} -- ${res.data[0].a}`); -// } -// }); - -// bot.addCommand('west-quote', { -// desc: `Say a random Kanye West quote.`, -// async function(from) { -// await this.say('> And here we go!'); -// let res = await axios.get('https://api.kanye.rest/'); -// await this.say(`> ${res.data.quote} -- Kanye West`); -// } -// }); + await this.say(`> I pick [${player.lvl}]${player.username}`) + } + }, // bot.addCommand('pink-quote', { // desc: `Say a random Pink Floyd quote.`, @@ -80,81 +144,12 @@ module.exports = { // } // }); -// bot.addCommand("fact", { -// desc: `Say a random fact.`, -// async function(from){ -// await this.say('> The internet says this is true?'); -// let res = await axios.get('https://uselessfacts.jsph.pl/random.json?language=en') -// await this.say( -// `> ${res.data.text}`, -// `> source: ${res.data.source}` -// ); -// } -// }); -// bot.addCommand("advice", { -// desc: `Say some random advice.`, -// async function(from){ -// await this.say('> Try this:'); -// let res = await axios.get('https://api.adviceslip.com/advice'); -// await this.say(`> ${res.data.slip.advice}`); -// } -// }); -// bot.addCommand('idea', { -// desc: `Say a random start up idea.`, -// async function(from){ -// await this.say('> How about?'); -// let res = await axios.get('https://itsthisforthis.com/api.php?text') -// await this.say(`> ${res.data}`); -// } -// }); -// bot.addCommand('discord', { -// desc: `Say the CJ discord invite link.`, -// async function(from) { -// await this.say('https://discord.gg/hyby9m8'); -// } -// }); -// bot.addCommand('dice',{ -// desc: `Roll a die. You can state the max size on the dice. Default is 6.`, -// async function(from, size){ -// size = size || 6; -// if(!Number.isInteger(Number(size))){ -// this.whisper(from, `${size} is not a whole number...`) -// return ; -// } -// await this.say( -// `> Rolling a dice for ${from}`, -// `> ${Math.floor(Math.random()*size)+1}` -// ); -// } -// }); -// bot.addCommand('random-player', { -// desc: `Return a random online player.`, -// async function(from){ -// let players = bot.getPlayers() - -// delete players[bot.bot.entity.username] -// let keys = Object.keys(players); -// let player = players[keys[ keys.length * Math.random() << 0]]; - -// await this.say(`> I pick [${player.lvl}]${player.username}`) -// } -// }); - -// bot.addCommand('flip', { -// desc: `Flip a coin.`, -// async function(from){ -// await this.say( -// `> Flipping a coin for ${from}`, -// `> ${!!(Math.floor(Math.random() * (3000 - 1500) + 1500)%2) ? "Heads" : "Tails"}` -// ); -// } -// }); };