diff --git a/commands/search/define.js b/commands/search/define.js index 442716a5..b58e0a01 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -29,7 +29,7 @@ module.exports = class DefineCommand extends Command { try { const { body } = await request .get(`http://api.wordnik.com:80/v4/word.json/${query}/definitions?limit=1&includeRelated=false&useCanonical=false&api_key=${WORDNIK_KEY}`); - if (body.length === 0) throw new Error('No Results.'); + if (!body.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0x9797FF) .setTitle(body[0].word) diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 5a2f2356..f502b85b 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -27,7 +27,7 @@ module.exports = class ForecastCommand extends Command { try { const { body } = await request .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); - if (body.query.count === 0) throw new Error('Location Not Found.'); + if (!body.query.count) throw new Error('Location Not Found.'); const forecasts = body.query.results.channel.item.forecast; const embed = new RichEmbed() .setColor(0x0000FF) diff --git a/commands/randomimg/konachan.js b/commands/search/konachan.js similarity index 93% rename from commands/randomimg/konachan.js rename to commands/search/konachan.js index 7569626c..be87a738 100644 --- a/commands/randomimg/konachan.js +++ b/commands/search/konachan.js @@ -5,7 +5,7 @@ module.exports = class KonachanCommand extends Command { constructor(client) { super(client, { name: 'konachan', - group: 'randomimg', + group: 'search', memberName: 'konachan', description: 'Sends a random (Possibly NSFW!) anime image from Konachan, with optional query.', guildOnly: true, @@ -28,6 +28,7 @@ module.exports = class KonachanCommand extends Command { try { const { body } = await request .get(`https://konachan.net/post.json?tags=${query ? `${query}%20` : ''}order:random&limit=1`); + if (!body.length) throw new Error('No Results.'); return msg.channel.send(query ? `Result for ${query}:` : 'Random Image:', { files: [`https:${body[0].file_url}`] }) .catch(err => msg.say(err)); } catch (err) { diff --git a/commands/search/osu.js b/commands/search/osu.js index fbe17ea6..9a8c1737 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -29,7 +29,7 @@ module.exports = class OsuCommand extends Command { try { const { body } = await request .get(`https://osu.ppy.sh/api/get_user?k=${OSU_KEY}&u=${query}&type=string`); - if (body.length === 0) throw new Error('No Results.'); + if (!body.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xFF66AA) .setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png') diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index 61a9025c..2d04c696 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -29,7 +29,7 @@ module.exports = class SoundCloudCommand extends Command { try { const { body } = await request .get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${SOUNDCLOUD_KEY}`); - if (body.length === 0) throw new Error('No Results.'); + if (!body.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xF15A22) .setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png') diff --git a/commands/search/urban.js b/commands/search/urban.js index f8aed81c..5f94b431 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -28,7 +28,7 @@ module.exports = class UrbanCommand extends Command { try { const { body } = await request .get(`http://api.urbandictionary.com/v0/define?term=${query}`); - if (body.list.length === 0) throw new Error('No Results.'); + if (!body.list.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0x32a8f0) .setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png') diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index b70830ce..99c6e971 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -30,7 +30,7 @@ module.exports = class WattpadCommand extends Command { const { body } = await request .get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`) .set({ 'Authorization': `Basic ${WATTPAD_KEY}` }); - if (body.stories.length === 0) throw new Error('No Results.'); + if (!body.stories.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xF89C34) .setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png') diff --git a/commands/search/weather.js b/commands/search/weather.js index d96eef20..5cb75856 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -27,7 +27,7 @@ module.exports = class WeatherCommand extends Command { try { const { body } = await request .get(`https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where u=\'f\' AND woeid in (select woeid from geo.places(1) where text="${query}")&format=json`); - if (body.query.count === 0) throw new Error('Location Not Found.'); + if (!body.query.count) throw new Error('Location Not Found.'); const embed = new RichEmbed() .setColor(0x0000FF) .setAuthor(body.query.results.channel.title, 'https://i.imgur.com/2MT0ViC.png') diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 50645c95..33257d1e 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -29,7 +29,7 @@ module.exports = class YouTubeCommand extends Command { try { const { body } = await request .get(`https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=1&q=${query}&key=${GOOGLE_KEY}`); - if (body.items.length === 0) throw new Error('No Results.'); + if (!body.items.length) throw new Error('No Results.'); const embed = new RichEmbed() .setColor(0xDD2825) .setTitle(body.items[0].snippet.title)