shorten in Util

This commit is contained in:
Daniel Odendahl Jr
2017-08-22 21:01:08 +00:00
parent 05e45fbb79
commit 1938b65786
14 changed files with 31 additions and 22 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
const Command = require('../../structures/Command');
const { MessageEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { cleanXML } = require('../../structures/Util');
const { cleanXML, shorten } = require('../../structures/Util');
const { promisify } = require('util');
const xml = promisify(require('xml2js').parseString);
const { ANIMELIST_LOGIN } = process.env;
@@ -31,14 +31,14 @@ module.exports = class AnimeCommand extends Command {
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`)
.query({ q: query });
const { anime } = await xml(text);
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2048));
const synopsis = cleanXML(anime.entry[0].synopsis[0]);
const embed = new MessageEmbed()
.setColor(0x2D54A2)
.setAuthor('My Anime List', 'https://i.imgur.com/R4bmNFz.png')
.setURL(`https://myanimelist.net/anime/${anime.entry[0].id[0]}`)
.setThumbnail(anime.entry[0].image[0])
.setTitle(`${anime.entry[0].title[0]} (English: ${anime.entry[0].english[0] || 'N/A'})`)
.setDescription(synopsis)
.setDescription(shorten(synopsis))
.addField(' Type',
`${anime.entry[0].type[0]} - ${anime.entry[0].status[0]}`, true)
.addField(' Episodes',