mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Rotten Tomatoes Scores
This commit is contained in:
@@ -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>"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ const { Command } = require('discord.js-commando');
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { shorten } = require('../../util/Util');
|
const { shorten } = require('../../util/Util');
|
||||||
|
const { critic, audience } = require('../../assets/json/rotten-tomatoes');
|
||||||
|
|
||||||
module.exports = class RottenTomatoesCommand extends Command {
|
module.exports = class RottenTomatoesCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -35,6 +36,8 @@ module.exports = class RottenTomatoesCommand extends Command {
|
|||||||
const urlID = find.url.replace('/m/', '');
|
const urlID = find.url.replace('/m/', '');
|
||||||
const { text } = await snekfetch.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${urlID}`);
|
const { text } = await snekfetch.get(`https://www.rottentomatoes.com/api/private/v1.0/movies/${urlID}`);
|
||||||
const body = JSON.parse(text);
|
const body = JSON.parse(text);
|
||||||
|
const criticScre = body.ratingSummary.allCritics;
|
||||||
|
const audienceScre = body.ratingSummary.audience;
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xFFEC02)
|
.setColor(0xFFEC02)
|
||||||
.setTitle(`${body.title} (${body.year})`)
|
.setTitle(`${body.title} (${body.year})`)
|
||||||
@@ -43,9 +46,9 @@ module.exports = class RottenTomatoesCommand extends Command {
|
|||||||
.setDescription(shorten(body.ratingSummary.consensus))
|
.setDescription(shorten(body.ratingSummary.consensus))
|
||||||
.setThumbnail(body.posters.original)
|
.setThumbnail(body.posters.original)
|
||||||
.addField('❯ Critic Score',
|
.addField('❯ Critic Score',
|
||||||
body.ratings.critics_score !== -1 ? `${body.ratings.critics_score}%` : '???', true)
|
criticScre.meterValue ? `${critic[criticScre.meterClass]} ${criticScre.meterValue}%` : '???', true)
|
||||||
.addField('❯ Audience Score',
|
.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);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "58.2.0",
|
"version": "58.2.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user