mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Clean HTML from wyptb
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { verify } = require('../../util/Util');
|
const { verify, cleanHTML } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class WillYouPressTheButtonCommand extends Command {
|
module.exports = class WillYouPressTheButtonCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -28,7 +28,7 @@ module.exports = class WillYouPressTheButtonCommand extends Command {
|
|||||||
try {
|
try {
|
||||||
const dilemma = await this.fetchDilemma();
|
const dilemma = await this.fetchDilemma();
|
||||||
await msg.reply(stripIndents`
|
await msg.reply(stripIndents`
|
||||||
**${dilemma.txt1}** but **${dilemma.txt2}**
|
**${cleanHTML(dilemma.txt1)}** but **${cleanHTML(dilemma.txt2)}**
|
||||||
|
|
||||||
Will you press the button?
|
Will you press the button?
|
||||||
_Respond with [y]es or [n]o to continue._
|
_Respond with [y]es or [n]o to continue._
|
||||||
|
|||||||
@@ -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, trimArray } = require('../../util/Util');
|
const { embedURL, cleanHTML, trimArray } = require('../../util/Util');
|
||||||
const searchGraphQL = stripIndents`
|
const searchGraphQL = stripIndents`
|
||||||
query ($search: String) {
|
query ($search: String) {
|
||||||
characters: Page (perPage: 1) {
|
characters: Page (perPage: 1) {
|
||||||
@@ -82,7 +82,7 @@ module.exports = class AnimeCharacterCommand extends Command {
|
|||||||
.setURL(character.siteUrl)
|
.setURL(character.siteUrl)
|
||||||
.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 ? cleanHTML(character.description, false) : 'No description.')
|
||||||
.addField('❯ Appearances', trimArray(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);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const { MessageEmbed } = require('discord.js');
|
|||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { cleanAnilistHTML, embedURL } = require('../../util/Util');
|
const { cleanHTML, 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) {
|
||||||
@@ -124,7 +124,7 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
.setURL(anime.siteUrl)
|
.setURL(anime.siteUrl)
|
||||||
.setThumbnail(anime.coverImage.large || anime.coverImage.medium || null)
|
.setThumbnail(anime.coverImage.large || anime.coverImage.medium || null)
|
||||||
.setTitle(anime.title.english || anime.title.romaji)
|
.setTitle(anime.title.english || anime.title.romaji)
|
||||||
.setDescription(anime.description ? cleanAnilistHTML(anime.description) : 'No description.')
|
.setDescription(anime.description ? cleanHTML(anime.description) : 'No description.')
|
||||||
.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)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const { MessageEmbed } = require('discord.js');
|
|||||||
const request = require('node-superfetch');
|
const request = require('node-superfetch');
|
||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { cleanAnilistHTML, embedURL } = require('../../util/Util');
|
const { cleanHTML, 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) {
|
||||||
@@ -118,7 +118,7 @@ module.exports = class MangaCommand extends Command {
|
|||||||
.setURL(manga.siteUrl)
|
.setURL(manga.siteUrl)
|
||||||
.setThumbnail(manga.coverImage.large || manga.coverImage.medium || null)
|
.setThumbnail(manga.coverImage.large || manga.coverImage.medium || null)
|
||||||
.setTitle(manga.title.english || manga.title.romaji)
|
.setTitle(manga.title.english || manga.title.romaji)
|
||||||
.setDescription(manga.description ? cleanAnilistHTML(manga.description) : 'No description.')
|
.setDescription(manga.description ? cleanHTML(manga.description) : 'No description.')
|
||||||
.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)
|
||||||
|
|||||||
+1
-1
@@ -202,7 +202,7 @@ module.exports = class Util {
|
|||||||
return verify.map(player => player.author.id);
|
return verify.map(player => player.author.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cleanAnilistHTML(html, removeLineBreaks = true) {
|
static cleanHTML(html, removeLineBreaks = true) {
|
||||||
let clean = html;
|
let clean = html;
|
||||||
if (removeLineBreaks) clean = clean.replace(/\r|\n|\f/g, '');
|
if (removeLineBreaks) clean = clean.replace(/\r|\n|\f/g, '');
|
||||||
clean = clean
|
clean = clean
|
||||||
|
|||||||
Reference in New Issue
Block a user