From d10987abd8f952bf1f8cce64410203829d611871 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 4 Dec 2017 18:39:26 +0000 Subject: [PATCH] Updates --- XiaoBot.js | 6 --- assets/json/activity.json | 28 ++++++++++++ assets/json/cards-against-humanity.json | 9 +++- commands/events/horoscope.js | 3 +- commands/games/apples-to-apples.js | 27 ++++++----- commands/games/cards-against-humanity.js | 27 ++++++----- commands/search/bot-info.js | 48 -------------------- commands/search/recipe.js | 45 ------------------ commands/search/what-3-words.js | 58 ------------------------ package.json | 2 +- 10 files changed, 64 insertions(+), 189 deletions(-) delete mode 100644 commands/search/bot-info.js delete mode 100644 commands/search/recipe.js delete mode 100644 commands/search/what-3-words.js diff --git a/XiaoBot.js b/XiaoBot.js index 877d4736..6162679f 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -56,12 +56,6 @@ client.on('warn', err => console.warn('[WARNING]', err)); client.on('commandError', (command, err) => console.error('[COMMAND ERROR]', command.name, err)); -client.dispatcher.addInhibitor(msg => { - if (msg.channel.type !== 'text' || !msg.channel.topic) return false; - if (msg.channel.topic.includes('')) return 'topic blocked'; - return false; -}); - client.login(XIAO_TOKEN); process.on('unhandledRejection', err => { diff --git a/assets/json/activity.json b/assets/json/activity.json index 940d0cfe..3bd446f8 100644 --- a/assets/json/activity.json +++ b/assets/json/activity.json @@ -38,5 +38,33 @@ { "text": "Travelers of the Wind", "type": "LISTENING" + }, + { + "text": "you eat pant", + "type": "WATCHING" + }, + { + "text": "anime", + "type": "WATCHING" + }, + { + "text": "with a big red button", + "type": "PLAYING" + }, + { + "text": "with you", + "type": "PLAYING" + }, + { + "text": "with a ban hammer", + "type": "PLAYING" + }, + { + "text": "you", + "type": "PLAYING" + }, + { + "text": "Nothing", + "type": "PLAYING" } ] diff --git a/assets/json/cards-against-humanity.json b/assets/json/cards-against-humanity.json index 675a9fc3..983342c5 100644 --- a/assets/json/cards-against-humanity.json +++ b/assets/json/cards-against-humanity.json @@ -3217,6 +3217,13 @@ "The Royal Canadian Mounted Police.", "An icy handjob from an Edmonton hooker.", "eat pant.", - "" + "", + "dragonfire535.", + "ebearskittychan.", + "XiaoBot.", + "XiaoBot's public source code.", + "Discord.", + "Beta.", + "Delta." ] } diff --git a/commands/events/horoscope.js b/commands/events/horoscope.js index 2b8fa1c2..b7c8e84e 100644 --- a/commands/events/horoscope.js +++ b/commands/events/horoscope.js @@ -30,8 +30,7 @@ module.exports = class HoroscopeCommand extends Command { async run(msg, { sign }) { try { - const { text } = await snekfetch.get(`http://sandipbgt.com/theastrologer/api/horoscope/${sign}/today/`); - const body = JSON.parse(text); + const { body } = await snekfetch.get(`http://theastrologer-api.herokuapp.com/api/horoscope/${sign}/today`); const embed = new MessageEmbed() .setColor(0x9797FF) .setTitle(`Horoscope for ${body.sunsign}...`) diff --git a/commands/games/apples-to-apples.js b/commands/games/apples-to-apples.js index a500ff92..f3795e21 100644 --- a/commands/games/apples-to-apples.js +++ b/commands/games/apples-to-apples.js @@ -87,20 +87,8 @@ module.exports = class ApplesToApplesCommand extends Command { continue; } if (chosen === '') { - await player.user.send(stripIndents` - What do you want the blank card to say? - Only answers under 100 characters will be counted. - `); - const blank = await player.user.dmChannel.awaitMessages(res => res.content.length < 100, { - max: 1, - time: 120000 - }); - if (!blank.size) { // eslint-disable-line max-depth - await player.user.send('Skipping your turn...'); - continue; - } - player.hand.delete(''); - chosen = blank.first().content; + const handled = await this.handleBlank(player); + chosen = handled; } else { player.hand.delete(chosen); } @@ -166,4 +154,15 @@ module.exports = class ApplesToApplesCommand extends Command { } return players; } + + async handleBlank(player) { + await player.user.send('What do you want the blank card to say? Must be 100 or less characters.'); + const blank = await player.user.dmChannel.awaitMessages(res => res.content.length <= 100, { + max: 1, + time: 120000 + }); + player.hand.delete(''); + if (!blank.size) return `A blank card ${player.user.tag} forgot to fill out.`; + return blank.first().content; + } }; diff --git a/commands/games/cards-against-humanity.js b/commands/games/cards-against-humanity.js index 76584b9a..72bc80d8 100644 --- a/commands/games/cards-against-humanity.js +++ b/commands/games/cards-against-humanity.js @@ -89,20 +89,8 @@ module.exports = class CardsAgainstHumanityCommand extends Command { continue; } if (chosen.includes('')) { - await player.user.send(stripIndents` - What do you want the blank card to say? - Only answers under 100 characters will be counted. - `); - const blank = await player.user.dmChannel.awaitMessages(res => res.content.length < 100, { - max: 1, - time: 120000 - }); - if (!blank.size) { // eslint-disable-line max-depth - await player.user.send('Skipping your turn...'); - continue; - } - player.hand.delete(''); - chosen[chosen.indexOf('')] = blank.first().content; + const handled = await this.handleBlank(player); + chosen[chosen.indexOf('')] = handled; } for (const card of chosen) player.hand.delete(card); chosenCards.push({ @@ -167,4 +155,15 @@ module.exports = class CardsAgainstHumanityCommand extends Command { } return players; } + + async handleBlank(player) { + await player.user.send('What do you want the blank card to say? Must be 100 or less characters.'); + const blank = await player.user.dmChannel.awaitMessages(res => res.content.length <= 100, { + max: 1, + time: 120000 + }); + player.hand.delete(''); + if (!blank.size) return `A blank card ${player.user.tag} forgot to fill out.`; + return blank.first().content; + } }; diff --git a/commands/search/bot-info.js b/commands/search/bot-info.js deleted file mode 100644 index 67149c7c..00000000 --- a/commands/search/bot-info.js +++ /dev/null @@ -1,48 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const snekfetch = require('snekfetch'); -const { DBOTS_KEY } = process.env; - -module.exports = class BotInfoCommand extends Command { - constructor(client) { - super(client, { - name: 'bot-info', - aliases: ['discord-bots', 'dbots'], - group: 'search', - memberName: 'bot-info', - description: 'Responds with information on a specific Discord bot.', - clientPermissions: ['EMBED_LINKS'], - args: [ - { - key: 'bot', - prompt: 'Which bot do you want to get information on?', - type: 'user' - } - ] - }); - } - - async run(msg, { bot }) { - try { - const { body } = await snekfetch - .get(`https://bots.discord.pw/api/bots/${bot.id}`) - .set({ Authorization: DBOTS_KEY }); - const embed = new MessageEmbed() - .setColor(0x9797FF) - .setAuthor('Discord Bots', 'https://i.imgur.com/tHTKaks.jpg') - .setTitle(body.name) - .setURL(`https://bots.discord.pw/bots/${bot.id}`) - .setDescription(body.description) - .addField('❯ Library', - body.library, true) - .addField('❯ Invite', - `[Here](${body.invite_url})`, true) - .addField('❯ Prefix', - body.prefix, true); - return msg.embed(embed); - } catch (err) { - if (err.status === 404) return msg.say('Could not find any results.'); - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/recipe.js b/commands/search/recipe.js deleted file mode 100644 index 3b938ed6..00000000 --- a/commands/search/recipe.js +++ /dev/null @@ -1,45 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const snekfetch = require('snekfetch'); - -module.exports = class RecipeCommand extends Command { - constructor(client) { - super(client, { - name: 'recipe', - aliases: ['recipe-puppy'], - group: 'search', - memberName: 'recipe', - description: 'Searches for recipes based on your query.', - clientPermissions: ['EMBED_LINKS'], - args: [ - { - key: 'query', - prompt: 'What recipe would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - try { - const { text } = await snekfetch - .get('http://www.recipepuppy.com/api/') - .query({ q: query }); - const body = JSON.parse(text); - if (!body.results.length) return msg.say('Could not find any results.'); - const recipe = body.results[Math.floor(Math.random() * body.results.length)]; - const embed = new MessageEmbed() - .setAuthor('Recipe Puppy', 'https://i.imgur.com/mn05Z8y.png') - .setColor(0xC20000) - .setURL(recipe.href) - .setTitle(recipe.title) - .setDescription(`**Ingredients**: ${recipe.ingredients}`) - .setThumbnail(recipe.thumbnail); - return msg.embed(embed); - } catch (err) { - if (err.status === 500) return msg.say('Could not find any results.'); - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/what-3-words.js b/commands/search/what-3-words.js deleted file mode 100644 index db6c6fcd..00000000 --- a/commands/search/what-3-words.js +++ /dev/null @@ -1,58 +0,0 @@ -const { Command } = require('discord.js-commando'); -const snekfetch = require('snekfetch'); -const { W3W_KEY, GOOGLE_KEY } = process.env; - -module.exports = class What3WordsCommand extends Command { - constructor(client) { - super(client, { - name: 'what-3-words', - aliases: ['what-three-words', 'w3w'], - group: 'search', - memberName: 'what-3-words', - description: 'Responds with a map based upon the 3 words you provide.', - clientPermissions: ['ATTACH_FILES'], - args: [ - { - key: 'zoom', - label: 'zoom level', - prompt: 'What would you like the zoom level to be? Must be a number from 1-20.', - type: 'integer', - min: 1, - max: 20 - }, - { - key: 'location', - prompt: 'What location would you like to get a map of? Use three nouns, like "cat.dog.parrot".', - type: 'string', - validate: location => { - if (location.split('.').length === 3) return true; - return 'Invalid location, please enter a valid location, like "cat.dog.parrot".'; - } - } - ] - }); - } - - async run(msg, { zoom, location }) { - try { - const { body } = await snekfetch - .get('https://api.what3words.com/v2/forward') - .query({ - addr: location, - key: W3W_KEY - }); - if (body.status.code === 300) return msg.say('Could not find any results.'); - const map = await snekfetch - .get('https://maps.googleapis.com/maps/api/staticmap') - .query({ - center: `${body.geometry.lat},${body.geometry.lng}`, - zoom, - size: '500x500', - key: GOOGLE_KEY - }); - return msg.say(`<${body.map}>`, { files: [{ attachment: map.body, name: 'what-3-words.png' }] }); - } catch (err) { - return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/package.json b/package.json index a5730003..a120a63f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "55.2.1", + "version": "56.0.0", "description": "Your personal server companion.", "main": "XiaoBot.js", "scripts": {