mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
MAL Scores Work Again
This commit is contained in:
@@ -1251,6 +1251,9 @@ 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)
|
||||||
- [Myinstants](https://www.myinstants.com/index/us/)
|
- [Myinstants](https://www.myinstants.com/index/us/)
|
||||||
* soundboard ([Various Meme Sounds](https://www.myinstants.com/search/?name=meme))
|
* soundboard ([Various Meme Sounds](https://www.myinstants.com/search/?name=meme))
|
||||||
- [Mythbusters](https://go.discovery.com/tv-shows/mythbusters)
|
- [Mythbusters](https://go.discovery.com/tv-shows/mythbusters)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
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 { cleanAnilistHTML } = require('../../util/Util');
|
const { cleanAnilistHTML, embedURL } = require('../../util/Util');
|
||||||
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
||||||
const searchGraphQL = stripIndents`
|
const searchGraphQL = stripIndents`
|
||||||
query ($search: String, $type: MediaType, $isAdult: Boolean) {
|
query ($search: String, $type: MediaType, $isAdult: Boolean) {
|
||||||
@@ -21,6 +22,7 @@ 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
|
||||||
@@ -88,6 +90,11 @@ 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: [
|
||||||
@@ -109,6 +116,8 @@ 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/')
|
||||||
@@ -119,8 +128,8 @@ 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('❯ Mean Score', anime.meanScore ? `${anime.meanScore}%` : '???', true)
|
|
||||||
.addField('❯ Average Score', anime.averageScore ? `${anime.averageScore}%` : '???', 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)
|
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', true)
|
||||||
.addField('❯ External Links', anime.externalLinks.length
|
.addField('❯ External Links', anime.externalLinks.length
|
||||||
? anime.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
|
? anime.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
|
||||||
@@ -158,6 +167,16 @@ 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,8 +1,9 @@
|
|||||||
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 { cleanAnilistHTML } = require('../../util/Util');
|
const { cleanAnilistHTML, embedURL } = require('../../util/Util');
|
||||||
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
const ANILIST_USERNAME = process.env.ANILIST_USERNAME || 'dragonfire535';
|
||||||
const searchGraphQL = stripIndents`
|
const searchGraphQL = stripIndents`
|
||||||
query ($search: String, $type: MediaType, $isAdult: Boolean) {
|
query ($search: String, $type: MediaType, $isAdult: Boolean) {
|
||||||
@@ -21,6 +22,7 @@ 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
|
||||||
@@ -82,6 +84,11 @@ 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: [
|
||||||
@@ -103,6 +110,8 @@ 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/')
|
||||||
@@ -113,8 +122,8 @@ 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('❯ Mean Score', manga.meanScore ? `${manga.meanScore}%` : '???', true)
|
|
||||||
.addField('❯ Average Score', manga.averageScore ? `${manga.averageScore}%` : '???', 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)
|
.addField(`❯ ${ANILIST_USERNAME}'s Score`, entry && entry.score ? `${entry.score}/10` : '???', true)
|
||||||
.addField('❯ External Links', manga.externalLinks.length
|
.addField('❯ External Links', manga.externalLinks.length
|
||||||
? manga.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
|
? manga.externalLinks.map(link => `[${link.site}](${link.url})`).join(', ')
|
||||||
@@ -152,6 +161,16 @@ 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.37.3",
|
"version": "116.37.4",
|
||||||
"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