mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-23 18:05:01 +02:00
Remove MAL Score from Anime and Manga
This commit is contained in:
@@ -1186,9 +1186,6 @@ here.
|
|||||||
* just-do-it ([Original Motivational Speech](https://www.youtube.com/watch?v=ZXsQAXx_ao0))
|
* just-do-it ([Original Motivational Speech](https://www.youtube.com/watch?v=ZXsQAXx_ao0))
|
||||||
- [muffinlabs - Today in History](http://history.muffinlabs.com/)
|
- [muffinlabs - Today in History](http://history.muffinlabs.com/)
|
||||||
* today-in-history ([API](http://history.muffinlabs.com/#api))
|
* today-in-history ([API](http://history.muffinlabs.com/#api))
|
||||||
- [MyAnimeList](https://myanimelist.net/)
|
|
||||||
* anime (Score Data)
|
|
||||||
* manga (Score Data)
|
|
||||||
- [Mythbusters](https://go.discovery.com/tv-shows/mythbusters)
|
- [Mythbusters](https://go.discovery.com/tv-shows/mythbusters)
|
||||||
* doors (Concept)
|
* doors (Concept)
|
||||||
- [NASA](https://www.nasa.gov/)
|
- [NASA](https://www.nasa.gov/)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { embedURL, cleanAnilistHTML } = require('../../util/Util');
|
const { embedURL, cleanAnilistHTML, trimArray } = require('../../util/Util');
|
||||||
const searchGraphQL = stripIndents`
|
const searchGraphQL = stripIndents`
|
||||||
query ($search: String) {
|
query ($search: String) {
|
||||||
characters: Page (perPage: 1) {
|
characters: Page (perPage: 1) {
|
||||||
@@ -83,10 +83,10 @@ module.exports = class AnimeCharacterCommand extends Command {
|
|||||||
.setThumbnail(character.image.large || character.image.medium || null)
|
.setThumbnail(character.image.large || character.image.medium || null)
|
||||||
.setTitle(`${character.name.first || ''}${character.name.last ? ` ${character.name.last}` : ''}`)
|
.setTitle(`${character.name.first || ''}${character.name.last ? ` ${character.name.last}` : ''}`)
|
||||||
.setDescription(character.description ? cleanAnilistHTML(character.description, false) : 'No description.')
|
.setDescription(character.description ? cleanAnilistHTML(character.description, false) : 'No description.')
|
||||||
.addField('❯ Appearances', character.media.edges.map(edge => {
|
.addField('❯ Appearances', trimArray(character.media.edges.map(edge => {
|
||||||
const title = edge.node.title.english || edge.node.title.userPreferred;
|
const title = edge.node.title.english || edge.node.title.userPreferred;
|
||||||
return embedURL(`${title} (${types[edge.node.type]})`, edge.node.siteUrl);
|
return embedURL(`${title} (${types[edge.node.type]})`, edge.node.siteUrl);
|
||||||
}).join(', '));
|
}), 10).join(', '));
|
||||||
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,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { embedURL, cleanAnilistHTML } = require('../../util/Util');
|
const { embedURL, cleanAnilistHTML } = require('../../util/Util');
|
||||||
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
||||||
@@ -22,7 +21,6 @@ const resultGraphQL = stripIndents`
|
|||||||
query media($id: Int, $type: MediaType) {
|
query media($id: Int, $type: MediaType) {
|
||||||
Media(id: $id, type: $type) {
|
Media(id: $id, type: $type) {
|
||||||
id
|
id
|
||||||
idMal
|
|
||||||
title {
|
title {
|
||||||
english
|
english
|
||||||
romaji
|
romaji
|
||||||
@@ -40,6 +38,7 @@ const resultGraphQL = stripIndents`
|
|||||||
episodes
|
episodes
|
||||||
isAdult
|
isAdult
|
||||||
meanScore
|
meanScore
|
||||||
|
averageScore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -85,11 +84,6 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
url: 'https://anilist.co/',
|
url: 'https://anilist.co/',
|
||||||
reason: 'API',
|
reason: 'API',
|
||||||
reasonURL: 'https://anilist.gitbook.io/anilist-apiv2-docs/'
|
reasonURL: 'https://anilist.gitbook.io/anilist-apiv2-docs/'
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'MyAnimeList',
|
|
||||||
url: 'https://myanimelist.net/',
|
|
||||||
reason: 'Score Data'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
@@ -111,8 +105,6 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
const anime = await this.fetchAnime(id);
|
const anime = await this.fetchAnime(id);
|
||||||
if (!this.personalList) await this.fetchPersonalList();
|
if (!this.personalList) await this.fetchPersonalList();
|
||||||
const entry = this.personalList.find(ani => ani.mediaId === id);
|
const entry = this.personalList.find(ani => ani.mediaId === id);
|
||||||
const malScore = await this.fetchMALScore(anime.idMal);
|
|
||||||
const malURL = `https://myanimelist.net/anime/${anime.idMal}`;
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0x02A9FF)
|
.setColor(0x02A9FF)
|
||||||
.setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/')
|
.setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/')
|
||||||
@@ -123,9 +115,9 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
.addField('❯ Status', statuses[anime.status], true)
|
.addField('❯ Status', statuses[anime.status], true)
|
||||||
.addField('❯ Episodes', anime.episodes || '???', true)
|
.addField('❯ Episodes', anime.episodes || '???', true)
|
||||||
.addField('❯ Season', anime.season ? `${seasons[anime.season]} ${anime.startDate.year}` : '???', true)
|
.addField('❯ Season', anime.season ? `${seasons[anime.season]} ${anime.startDate.year}` : '???', true)
|
||||||
.addField('❯ Average Score', anime.meanScore ? `${anime.meanScore}%` : '???', true)
|
.addField('❯ Mean Score', anime.meanScore ? `${anime.meanScore}%` : '???', true)
|
||||||
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '?/10', true)
|
.addField('❯ Average Score', anime.averageScore ? `${anime.averageScore}%` : '???', true)
|
||||||
.addField(`❯ MAL Score`, malScore ? embedURL(malScore, malURL) : '???', true);
|
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', 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!`);
|
||||||
@@ -159,16 +151,6 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
return body.data.Media;
|
return body.data.Media;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchMALScore(id) {
|
|
||||||
try {
|
|
||||||
const { text } = await request.get(`https://myanimelist.net/anime/${id}`);
|
|
||||||
const $ = cheerio.load(text);
|
|
||||||
return $('span[itemprop="ratingValue"]').first().text();
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchPersonalList() {
|
async fetchPersonalList() {
|
||||||
if (this.personalList) return this.personalList;
|
if (this.personalList) return this.personalList;
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const cheerio = require('cheerio');
|
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { embedURL, cleanAnilistHTML } = require('../../util/Util');
|
const { embedURL, cleanAnilistHTML } = require('../../util/Util');
|
||||||
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
||||||
@@ -22,7 +21,6 @@ const resultGraphQL = stripIndents`
|
|||||||
query media($id: Int, $type: MediaType) {
|
query media($id: Int, $type: MediaType) {
|
||||||
Media(id: $id, type: $type) {
|
Media(id: $id, type: $type) {
|
||||||
id
|
id
|
||||||
idMal
|
|
||||||
title {
|
title {
|
||||||
english
|
english
|
||||||
romaji
|
romaji
|
||||||
@@ -40,6 +38,7 @@ const resultGraphQL = stripIndents`
|
|||||||
chapters
|
chapters
|
||||||
isAdult
|
isAdult
|
||||||
meanScore
|
meanScore
|
||||||
|
averageScore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@@ -79,11 +78,6 @@ module.exports = class MangaCommand extends Command {
|
|||||||
url: 'https://anilist.co/',
|
url: 'https://anilist.co/',
|
||||||
reason: 'API',
|
reason: 'API',
|
||||||
reasonURL: 'https://anilist.gitbook.io/anilist-apiv2-docs/'
|
reasonURL: 'https://anilist.gitbook.io/anilist-apiv2-docs/'
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'MyAnimeList',
|
|
||||||
url: 'https://myanimelist.net/',
|
|
||||||
reason: 'Score Data'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
args: [
|
args: [
|
||||||
@@ -105,8 +99,6 @@ module.exports = class MangaCommand extends Command {
|
|||||||
const manga = await this.fetchManga(id);
|
const manga = await this.fetchManga(id);
|
||||||
if (!this.personalList) await this.fetchPersonalList();
|
if (!this.personalList) await this.fetchPersonalList();
|
||||||
const entry = this.personalList.find(ma => ma.mediaId === id);
|
const entry = this.personalList.find(ma => ma.mediaId === id);
|
||||||
const malScore = await this.fetchMALScore(manga.idMal);
|
|
||||||
const malURL = `https://myanimelist.net/manga/${manga.idMal}`;
|
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0x02A9FF)
|
.setColor(0x02A9FF)
|
||||||
.setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/')
|
.setAuthor('AniList', 'https://i.imgur.com/iUIRC7v.png', 'https://anilist.co/')
|
||||||
@@ -117,9 +109,9 @@ module.exports = class MangaCommand extends Command {
|
|||||||
.addField('❯ Status', statuses[manga.status], true)
|
.addField('❯ Status', statuses[manga.status], true)
|
||||||
.addField('❯ Chapters / Volumes', `${manga.chapters || '???'}/${manga.volumes || '???'}`, true)
|
.addField('❯ Chapters / Volumes', `${manga.chapters || '???'}/${manga.volumes || '???'}`, true)
|
||||||
.addField('❯ Year', manga.startDate.year || '???', true)
|
.addField('❯ Year', manga.startDate.year || '???', true)
|
||||||
.addField('❯ Average Score', manga.meanScore ? `${manga.meanScore}%` : '???', true)
|
.addField('❯ Mean Score', manga.meanScore ? `${manga.meanScore}%` : '???', true)
|
||||||
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '?/10', true)
|
.addField('❯ Average Score', manga.averageScore ? `${manga.averageScore}%` : '???', true)
|
||||||
.addField(`❯ MAL Score`, malScore ? embedURL(malScore, malURL) : '???', true);
|
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', 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!`);
|
||||||
@@ -153,16 +145,6 @@ module.exports = class MangaCommand extends Command {
|
|||||||
return body.data.Media;
|
return body.data.Media;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchMALScore(id) {
|
|
||||||
try {
|
|
||||||
const { text } = await request.get(`https://myanimelist.net/manga/${id}`);
|
|
||||||
const $ = cheerio.load(text);
|
|
||||||
return $('span[itemprop="ratingValue"]').first().text();
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchPersonalList() {
|
async fetchPersonalList() {
|
||||||
if (this.personalList) return this.personalList;
|
if (this.personalList) return this.personalList;
|
||||||
const { body } = await request
|
const { body } = await request
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "116.9.2",
|
"version": "116.9.3",
|
||||||
"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