mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-14 08:08:34 +02:00
promisifyAll in xml2js
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { RichEmbed } = require('discord.js');
|
const { RichEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { promisify } = require('tsubaki');
|
const { promisifyAll } = require('tsubaki');
|
||||||
const xml = promisify(require('xml2js').parseString);
|
const xml = promisifyAll(require('xml2js'));
|
||||||
const { ANIMELIST_LOGIN } = process.env;
|
const { ANIMELIST_LOGIN } = process.env;
|
||||||
|
|
||||||
module.exports = class AnimeCommand extends Command {
|
module.exports = class AnimeCommand extends Command {
|
||||||
@@ -33,7 +33,7 @@ module.exports = class AnimeCommand extends Command {
|
|||||||
.query({
|
.query({
|
||||||
q: query
|
q: query
|
||||||
});
|
});
|
||||||
const { anime } = await xml(text);
|
const { anime } = await xml.parseString(text);
|
||||||
const synopsis = anime.entry[0].synopsis[0].substr(0, 2000)
|
const synopsis = anime.entry[0].synopsis[0].substr(0, 2000)
|
||||||
.replace(/(<br \/>)/g, '')
|
.replace(/(<br \/>)/g, '')
|
||||||
.replace(/(')/g, '\'')
|
.replace(/(')/g, '\'')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { promisify } = require('tsubaki');
|
const { promisifyAll } = require('tsubaki');
|
||||||
const xml = promisify(require('xml2js').parseString);
|
const xml = promisifyAll(require('xml2js'));
|
||||||
|
|
||||||
module.exports = class GelbooruCommand extends Command {
|
module.exports = class GelbooruCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -33,7 +33,7 @@ module.exports = class GelbooruCommand extends Command {
|
|||||||
tags: query,
|
tags: query,
|
||||||
limit: 1
|
limit: 1
|
||||||
});
|
});
|
||||||
const { posts } = await xml(text);
|
const { posts } = await xml.parseString(text);
|
||||||
if (posts.$.count === '0') throw new Error('No Results.');
|
if (posts.$.count === '0') throw new Error('No Results.');
|
||||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { RichEmbed } = require('discord.js');
|
const { RichEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { promisify } = require('tsubaki');
|
const { promisifyAll } = require('tsubaki');
|
||||||
const xml = promisify(require('xml2js').parseString);
|
const xml = promisifyAll(require('xml2js'));
|
||||||
const { ANIMELIST_LOGIN } = process.env;
|
const { ANIMELIST_LOGIN } = process.env;
|
||||||
|
|
||||||
module.exports = class MangaCommand extends Command {
|
module.exports = class MangaCommand extends Command {
|
||||||
@@ -33,7 +33,7 @@ module.exports = class MangaCommand extends Command {
|
|||||||
.query({
|
.query({
|
||||||
q: query
|
q: query
|
||||||
});
|
});
|
||||||
const { manga } = await xml(text);
|
const { manga } = await xml.parseString(text);
|
||||||
const synopsis = manga.entry[0].synopsis[0].substr(0, 2000)
|
const synopsis = manga.entry[0].synopsis[0].substr(0, 2000)
|
||||||
.replace(/(<br \/>)/g, '')
|
.replace(/(<br \/>)/g, '')
|
||||||
.replace(/(')/g, '\'')
|
.replace(/(')/g, '\'')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { promisify } = require('tsubaki');
|
const { promisifyAll } = require('tsubaki');
|
||||||
const xml = promisify(require('xml2js').parseString);
|
const xml = promisifyAll(require('xml2js'));
|
||||||
|
|
||||||
module.exports = class Rule34Command extends Command {
|
module.exports = class Rule34Command extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -33,7 +33,7 @@ module.exports = class Rule34Command extends Command {
|
|||||||
tags: query,
|
tags: query,
|
||||||
limit: 1
|
limit: 1
|
||||||
});
|
});
|
||||||
const { posts } = await xml(text);
|
const { posts } = await xml.parseString(text);
|
||||||
if (posts.$.count === '0') throw new Error('No Results.');
|
if (posts.$.count === '0') throw new Error('No Results.');
|
||||||
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
return msg.say(`Result for ${query}: https:${posts.post[0].$.file_url}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "21.2.1",
|
"version": "21.2.2",
|
||||||
"description": "A Discord Bot",
|
"description": "A Discord Bot",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user