From 2dd81a23ea339cbe3e98e76d9ebc82c328959f3e Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 10 Jun 2018 01:26:20 +0000 Subject: [PATCH] Why does this even work --- commands/games/google-feud.js | 9 ++------- commands/search/kitsu-anime.js | 3 ++- commands/search/kitsu-manga.js | 3 ++- commands/search/league-of-legends-champion.js | 2 +- commands/search/neopets-item.js | 2 +- commands/search/rotten-tomatoes.js | 2 +- commands/search/rule-of-the-internet.js | 2 +- commands/search/youtube.js | 2 +- commands/voice/dec-talk.js | 16 +++++++++++----- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/commands/games/google-feud.js b/commands/games/google-feud.js index b764ecfc..d2018140 100644 --- a/commands/games/google-feud.js +++ b/commands/games/google-feud.js @@ -48,13 +48,8 @@ module.exports = class GoogleFeudCommand extends Command { break; } const choice = msgs.first().content.toLowerCase(); - if (suggestions.includes(choice)) { - await msg.say('Nice job!'); - display[suggestions.indexOf(choice)] = choice; - } else { - --tries; - if (tries) await msg.say(`Nope! ${tries} tries remaining!`); - } + if (suggestions.includes(choice)) display[suggestions.indexOf(choice)] = choice; + else --tries; } this.playing.delete(msg.channel.id); if (!display.includes('???')) return msg.say('You win! Nice job, master of Google!'); diff --git a/commands/search/kitsu-anime.js b/commands/search/kitsu-anime.js index 64cb1d3a..73db6916 100644 --- a/commands/search/kitsu-anime.js +++ b/commands/search/kitsu-anime.js @@ -24,9 +24,10 @@ module.exports = class KitsuAnimeCommand extends Command { async run(msg, { query }) { try { - const { body } = await request + const { text } = await request .get('https://kitsu.io/api/edge/anime') .query({ 'filter[text]': query }); + const body = JSON.parse(text); if (!body.data.length) return msg.say('Could not find any results.'); const data = body.data[0].attributes; const embed = new MessageEmbed() diff --git a/commands/search/kitsu-manga.js b/commands/search/kitsu-manga.js index 857e9b46..efd73d72 100644 --- a/commands/search/kitsu-manga.js +++ b/commands/search/kitsu-manga.js @@ -24,9 +24,10 @@ module.exports = class KitsuMangaCommand extends Command { async run(msg, { query }) { try { - const { body } = await request + const { text } = await request .get('https://kitsu.io/api/edge/manga') .query({ 'filter[text]': query }); + const body = JSON.parse(text); if (!body.data.length) return msg.say('Could not find any results.'); const data = body.data[0].attributes; const embed = new MessageEmbed() diff --git a/commands/search/league-of-legends-champion.js b/commands/search/league-of-legends-champion.js index 5ac7508a..acd8c10c 100644 --- a/commands/search/league-of-legends-champion.js +++ b/commands/search/league-of-legends-champion.js @@ -8,7 +8,7 @@ module.exports = class LeagueOfLegendsChampionCommand extends Command { constructor(client) { super(client, { name: 'league-of-legends-champion', - aliases: ['lol-champion', 'league-of-legends-champ', 'lol-champ'], + aliases: ['lol-champion', 'league-of-legends-champ', 'lol-champ', 'league-champ'], group: 'search', memberName: 'league-of-legends-champion', description: 'Responds with information on a League of Legends champion.', diff --git a/commands/search/neopets-item.js b/commands/search/neopets-item.js index 76166dfe..2a14a929 100644 --- a/commands/search/neopets-item.js +++ b/commands/search/neopets-item.js @@ -24,7 +24,7 @@ module.exports = class NeopetsItemCommand extends Command { async run(msg, { item }) { try { const data = await this.fetchItem(item); - if (!data) return msg.say('Could not find any results'); + if (!data) return msg.say('Could not find any results.'); const embed = new MessageEmbed() .setColor(0xFFCE31) .setAuthor('Neopets', 'https://i.imgur.com/BP8qxJH.png', 'http://www.neopets.com/') diff --git a/commands/search/rotten-tomatoes.js b/commands/search/rotten-tomatoes.js index b72db294..123a6944 100644 --- a/commands/search/rotten-tomatoes.js +++ b/commands/search/rotten-tomatoes.js @@ -7,7 +7,7 @@ module.exports = class RottenTomatoesCommand extends Command { constructor(client) { super(client, { name: 'rotten-tomatoes', - aliases: ['tomato-meter'], + aliases: ['tomato-meter', 'r-tomatoes'], group: 'search', memberName: 'rotten-tomatoes', description: 'Searches Rotten Tomatoes for your query.', diff --git a/commands/search/rule-of-the-internet.js b/commands/search/rule-of-the-internet.js index db5aafa6..ab56d5c5 100644 --- a/commands/search/rule-of-the-internet.js +++ b/commands/search/rule-of-the-internet.js @@ -5,7 +5,7 @@ module.exports = class RuleOfTheInternetCommand extends Command { constructor(client) { super(client, { name: 'rule-of-the-internet', - aliases: ['rules-of-the-internet', 'internet-rule', 'rule'], + aliases: ['rules-of-the-internet', 'internet-rule', 'rule', 'rules'], group: 'search', memberName: 'rule-of-the-internet', description: 'Responds with a rule of the internet.', diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 5968f69f..20706c9e 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -7,7 +7,7 @@ module.exports = class YoutubeCommand extends Command { constructor(client) { super(client, { name: 'youtube', - aliases: ['youtube-video'], + aliases: ['youtube-video', 'y-tube', 'u-tube'], group: 'search', memberName: 'youtube', description: 'Searches YouTube for your query.', diff --git a/commands/voice/dec-talk.js b/commands/voice/dec-talk.js index d9fedd0d..b5df918c 100644 --- a/commands/voice/dec-talk.js +++ b/commands/voice/dec-talk.js @@ -35,11 +35,17 @@ module.exports = class DECTalkCommand extends Command { if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.'); try { const connection = await channel.join(); - const { headers } = await request - .get('http://tts.cyzon.us/tts') - .query({ text }) - .redirects(0); - const dispatcher = connection.play(`http://tts.cyzon.us${headers.location}`); + let url = 'http://tts.cyzon.us'; + try { + await request + .get('http://tts.cyzon.us/tts') + .query({ text }) + .redirects(0); + } catch (err) { + if (err.headers.location) url += err.headers.location; + else throw err; + } + const dispatcher = connection.play(url); dispatcher.once('finish', () => channel.leave()); dispatcher.once('error', () => channel.leave()); return null;