diff --git a/assets/json/rotten-tomatoes.json b/assets/json/rotten-tomatoes.json new file mode 100644 index 00000000..f8757609 --- /dev/null +++ b/assets/json/rotten-tomatoes.json @@ -0,0 +1,11 @@ +{ + "critic": { + "certified": "<:certified_fresh:391778461951459339>", + "fresh": "<:red_tomato:391778462974607360>", + "rotten": "<:splat_tomato:391778462194728961>" + }, + "audience": { + "fresh": "<:standing_popcorn:391778463045910538>", + "rotten": "<:tipped_popcorn:391778462312169472>" + } +} diff --git a/commands/search/rotten-tomatoes.js b/commands/search/rotten-tomatoes.js index 1819e767..1126766e 100644 --- a/commands/search/rotten-tomatoes.js +++ b/commands/search/rotten-tomatoes.js @@ -2,6 +2,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); const { shorten } = require('../../util/Util'); +const { critic, audience } = require('../../assets/json/rotten-tomatoes'); module.exports = class RottenTomatoesCommand extends Command { constructor(client) { @@ -35,6 +36,8 @@ module.exports = class RottenTomatoesCommand extends Command { const urlID = find.url.replace('/m/', ''); const { text } = await snekfetch.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${urlID}`); const body = JSON.parse(text); + const criticScre = body.ratingSummary.allCritics; + const audienceScre = body.ratingSummary.audience; const embed = new MessageEmbed() .setColor(0xFFEC02) .setTitle(`${body.title} (${body.year})`) @@ -43,9 +46,9 @@ module.exports = class RottenTomatoesCommand extends Command { .setDescription(shorten(body.ratingSummary.consensus)) .setThumbnail(body.posters.original) .addField('❯ Critic Score', - body.ratings.critics_score !== -1 ? `${body.ratings.critics_score}%` : '???', true) + criticScre.meterValue ? `${critic[criticScre.meterClass]} ${criticScre.meterValue}%` : '???', true) .addField('❯ Audience Score', - body.ratings.audience_score !== -1 ? `${body.ratings.audience_score}%` : '???', true); + audienceScre.meterValue ? `${audience[audienceScre.meterClass]} ${audienceScre.meterValue}%` : '???', true); return msg.embed(embed); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/package.json b/package.json index 2ee041b8..dbb8e7e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "58.2.0", + "version": "58.2.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {