From 1e2a0d48ed2ffd268ced1b5fac2a161a3044d259 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Thu, 25 May 2017 23:50:48 +0000 Subject: [PATCH] promisifyAll in xml2js --- commands/search/anime.js | 6 +++--- commands/search/gelbooru.js | 6 +++--- commands/search/manga.js | 6 +++--- commands/search/rule34.js | 6 +++--- package.json | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/commands/search/anime.js b/commands/search/anime.js index 24ccf419..ab74ee67 100644 --- a/commands/search/anime.js +++ b/commands/search/anime.js @@ -1,8 +1,8 @@ const { Command } = require('discord.js-commando'); const { RichEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { promisify } = require('tsubaki'); -const xml = promisify(require('xml2js').parseString); +const { promisifyAll } = require('tsubaki'); +const xml = promisifyAll(require('xml2js')); const { ANIMELIST_LOGIN } = process.env; module.exports = class AnimeCommand extends Command { @@ -33,7 +33,7 @@ module.exports = class AnimeCommand extends Command { .query({ q: query }); - const { anime } = await xml(text); + const { anime } = await xml.parseString(text); const synopsis = anime.entry[0].synopsis[0].substr(0, 2000) .replace(/(
)/g, '') .replace(/(')/g, '\'') diff --git a/commands/search/gelbooru.js b/commands/search/gelbooru.js index eb4983df..c0cc68a6 100644 --- a/commands/search/gelbooru.js +++ b/commands/search/gelbooru.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const snekfetch = require('snekfetch'); -const { promisify } = require('tsubaki'); -const xml = promisify(require('xml2js').parseString); +const { promisifyAll } = require('tsubaki'); +const xml = promisifyAll(require('xml2js')); module.exports = class GelbooruCommand extends Command { constructor(client) { @@ -33,7 +33,7 @@ module.exports = class GelbooruCommand extends Command { tags: query, limit: 1 }); - const { posts } = await xml(text); + const { posts } = await xml.parseString(text); if (posts.$.count === '0') throw new Error('No Results.'); return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`); } catch (err) { diff --git a/commands/search/manga.js b/commands/search/manga.js index 6df549bb..c2310566 100644 --- a/commands/search/manga.js +++ b/commands/search/manga.js @@ -1,8 +1,8 @@ const { Command } = require('discord.js-commando'); const { RichEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { promisify } = require('tsubaki'); -const xml = promisify(require('xml2js').parseString); +const { promisifyAll } = require('tsubaki'); +const xml = promisifyAll(require('xml2js')); const { ANIMELIST_LOGIN } = process.env; module.exports = class MangaCommand extends Command { @@ -33,7 +33,7 @@ module.exports = class MangaCommand extends Command { .query({ q: query }); - const { manga } = await xml(text); + const { manga } = await xml.parseString(text); const synopsis = manga.entry[0].synopsis[0].substr(0, 2000) .replace(/(
)/g, '') .replace(/(')/g, '\'') diff --git a/commands/search/rule34.js b/commands/search/rule34.js index 4ba5c77c..c5aaf4c0 100644 --- a/commands/search/rule34.js +++ b/commands/search/rule34.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const snekfetch = require('snekfetch'); -const { promisify } = require('tsubaki'); -const xml = promisify(require('xml2js').parseString); +const { promisifyAll } = require('tsubaki'); +const xml = promisifyAll(require('xml2js')); module.exports = class Rule34Command extends Command { constructor(client) { @@ -33,7 +33,7 @@ module.exports = class Rule34Command extends Command { tags: query, limit: 1 }); - const { posts } = await xml(text); + const { posts } = await xml.parseString(text); if (posts.$.count === '0') throw new Error('No Results.'); return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`); } catch (err) { diff --git a/package.json b/package.json index ab6116c1..3d82da61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "21.2.1", + "version": "21.2.2", "description": "A Discord Bot", "main": "Shard.js", "scripts": {