diff --git a/commands/games/akinator.js b/commands/games/akinator.js index b72505ee..beddfef2 100644 --- a/commands/games/akinator.js +++ b/commands/games/akinator.js @@ -24,7 +24,7 @@ module.exports = class AkinatorCommand extends Command { this.sessions.set(msg.channel.id, { progress: null }); while (this.sessions.get(msg.channel.id).progress < 99) { const data = ans === null ? await this.createSession(msg.channel) : await this.progress(msg.channel, ans); - if (this.sessions.get(msg.channel.id).step >= 80) break; + if (!data || this.sessions.get(msg.channel.id).step >= 80) break; const answers = data.answers.map(answer => answer.answer.toLowerCase()); answers.push('end'); await msg.say(stripIndents` @@ -76,6 +76,7 @@ module.exports = class AkinatorCommand extends Command { player: 'xiaobot' }); const data = body.parameters; + if (!data) return null; this.sessions.set(channel.id, { id: data.identification.session, signature: data.identification.signature, @@ -95,13 +96,15 @@ module.exports = class AkinatorCommand extends Command { step: session.step, answer }); + const data = body.parameters; + if (!data) return null; this.sessions.set(channel.id, { id: session.id, signature: session.signature, - step: parseInt(body.parameters.step, 10), - progress: parseInt(body.parameters.progression, 10) + step: parseInt(data.step, 10), + progress: parseInt(data.progression, 10) }); - return body.parameters; + return data; } async finish(channel) { diff --git a/commands/image-edit/pokemon-fusion.js b/commands/image-edit/pokemon-fusion.js index b6d8513d..7de9807f 100644 --- a/commands/image-edit/pokemon-fusion.js +++ b/commands/image-edit/pokemon-fusion.js @@ -1,4 +1,5 @@ const { Command } = require('discord.js-commando'); +const snekfetch = require('snekfetch'); const pokemon = require('../../assets/json/pokemon-fusion'); module.exports = class PokemonFusionCommand extends Command { @@ -35,7 +36,12 @@ module.exports = class PokemonFusionCommand extends Command { }); } - run(msg, { body, palette }) { - return msg.say({ files: [`http://images.alexonsager.net/pokemon/fused/${body}/${body}.${palette}.png`] }); + async run(msg, { body, palette }) { + try { + const image = await snekfetch.get(`http://images.alexonsager.net/pokemon/fused/${body}/${body}.${palette}.png`); + return msg.say({ files: [{ attachment: image.body, name: 'pokemon-fusion.png' }] }); + } catch (err) { + return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } } }; diff --git a/commands/other/soundboard.js b/commands/other/soundboard.js index a7a4cac6..f8c659c9 100644 --- a/commands/other/soundboard.js +++ b/commands/other/soundboard.js @@ -50,7 +50,7 @@ module.exports = class SoundboardCommand extends Command { return null; } catch (err) { channel.leave(); - return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + throw err; } } }; diff --git a/commands/search/recipe.js b/commands/search/recipe.js index 6dd032dc..9d76f232 100644 --- a/commands/search/recipe.js +++ b/commands/search/recipe.js @@ -38,7 +38,8 @@ module.exports = class RecipeCommand extends Command { .setThumbnail(recipe.thumbnail); return msg.embed(embed); } catch (err) { - return msg.say('Could not find any results.'); + if (err.status === 500) return msg.say('Could not find any results.'); + return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); } } }; diff --git a/commands/search/steam.js b/commands/search/steam.js index 0d261c9c..9c07ad8e 100644 --- a/commands/search/steam.js +++ b/commands/search/steam.js @@ -40,15 +40,17 @@ module.exports = class SteamCommand extends Command { const original = data.price_overview ? data.price_overview.initial / 100 : 0; const price = current === original ? `$${current}` : `~~$${original}~~ $${current}`; const platforms = []; - if (data.platforms.windows) platforms.push('Windows'); - if (data.platforms.mac) platforms.push('Mac'); - if (data.platforms.linux) platforms.push('Linux'); + if (data.platforms) { + if (data.platforms.windows) platforms.push('Windows'); + if (data.platforms.mac) platforms.push('Mac'); + if (data.platforms.linux) platforms.push('Linux'); + } const embed = new MessageEmbed() .setColor(0x101D2F) .setAuthor('Steam', 'https://i.imgur.com/xxr2UBZ.png') .setTitle(data.name) .setURL(`http://store.steampowered.com/app/${data.steam_appid}`) - .setImage(data.header_image) + .setThumbnail(search.body.tiny_image) .addField('❯ Price', price, true) .addField('❯ Metascore', @@ -57,6 +59,10 @@ module.exports = class SteamCommand extends Command { data.recommendations ? data.recommendations.total : 'N/A', true) .addField('❯ Platforms', platforms.join(', ') || 'None', true) + .addField('❯ Release Data', + data.release_date ? data.release_date.date : 'N/A', true) + .addField('❯ DLC Count', + data.dlc ? data.dlc.length : 0, true) .addField('❯ Developers', data.developers.join(', ') || 'N/A') .addField('❯ Publishers', diff --git a/commands/search/vocaloid.js b/commands/search/vocaloid.js index 1fee7931..c0ff02a9 100644 --- a/commands/search/vocaloid.js +++ b/commands/search/vocaloid.js @@ -42,7 +42,7 @@ module.exports = class VocaloidCommand extends Command { .setAuthor('VocaDB', 'https://i.imgur.com/6QwraDT.jpg') .setTitle(data.name) .setURL(`http://vocadb.net/S/${data.id}`) - .setDescription(data.lyrics.length ? shorten(data.lyrics[0].value) : 'N/A') + .setDescription(data.lyrics.length ? shorten(data.lyrics[0].value) : 'No lyrics available.') .setThumbnail(data.thumbUrl) .addField('❯ Artist', data.artistString) diff --git a/package.json b/package.json index fdcd0dea..6a14e4c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "47.0.1", + "version": "47.0.2", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {