mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 22:14:34 +02:00
Remove tsubaki, better wait in gunfight
This commit is contained in:
+12
-13
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { wait } = require('../../structures/Util');
|
||||
const words = ['fire', 'draw', 'shoot', 'bang', 'pull'];
|
||||
|
||||
module.exports = class GunfightCommand extends Command {
|
||||
@@ -40,19 +41,17 @@ module.exports = class GunfightCommand extends Command {
|
||||
}
|
||||
await msg.say('Get Ready...');
|
||||
const length = Math.floor(Math.random() * ((30000 - 1000) + 1)) + 1000;
|
||||
this.client.setTimeout(async () => {
|
||||
const word = words[Math.floor(Math.random() * words.length)];
|
||||
await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`);
|
||||
const filter = res => [opponent.id, msg.author.id].includes(res.author.id) && res.content.toLowerCase() === word; // eslint-disable-line max-len
|
||||
const winner = await msg.channel.awaitMessages(filter, {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
this.fighting.delete(msg.guild.id);
|
||||
if (!winner.size) return msg.say('Oh... No one won.');
|
||||
return msg.say(`And the winner is ${winner.first().author.username}!`);
|
||||
}, length);
|
||||
return null;
|
||||
await wait(length);
|
||||
const word = words[Math.floor(Math.random() * words.length)];
|
||||
await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`);
|
||||
const filter = res => [opponent.id, msg.author.id].includes(res.author.id) && res.content.toLowerCase() === word;
|
||||
const winner = await msg.channel.awaitMessages(filter, {
|
||||
max: 1,
|
||||
time: 30000
|
||||
});
|
||||
this.fighting.delete(msg.guild.id);
|
||||
if (!winner.size) return msg.say('Oh... No one won.');
|
||||
return msg.say(`And the winner is ${winner.first().author.username}!`);
|
||||
} catch (err) {
|
||||
this.fighting.delete(msg.guild.id);
|
||||
return msg.say(`Oh no, an Error occurred: \`${err.message}\`. Try again later!`);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
|
||||
module.exports = class GelbooruCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -34,7 +34,7 @@ module.exports = class GelbooruCommand extends Command {
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
const { posts } = await xml(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
|
||||
module.exports = class Rule34Command extends Command {
|
||||
constructor(client) {
|
||||
@@ -34,7 +34,7 @@ module.exports = class Rule34Command extends Command {
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
const { posts } = await xml(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
|
||||
module.exports = class SafebooruCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -34,7 +34,7 @@ module.exports = class SafebooruCommand extends Command {
|
||||
tags: query,
|
||||
limit: 200
|
||||
});
|
||||
const { posts } = await xml.parseStringAsync(text);
|
||||
const { posts } = await xml(text);
|
||||
if (posts.$.count === '0') return msg.say('No Results.');
|
||||
return msg.say(stripIndents`
|
||||
${query ? `Result for ${query}:` : 'Random Image:'}
|
||||
|
||||
@@ -2,8 +2,8 @@ const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { cleanXML } = require('../../structures/Util');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
|
||||
module.exports = class AnimeCommand extends Command {
|
||||
@@ -30,7 +30,7 @@ module.exports = class AnimeCommand extends Command {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/anime/search.xml`)
|
||||
.query({ q: query });
|
||||
const { anime } = await xml.parseStringAsync(text);
|
||||
const { anime } = await xml(text);
|
||||
const synopsis = cleanXML(anime.entry[0].synopsis[0].substr(0, 2048));
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
|
||||
@@ -2,8 +2,8 @@ const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { cleanXML } = require('../../structures/Util');
|
||||
const { promisifyAll } = require('tsubaki');
|
||||
const xml = promisifyAll(require('xml2js'));
|
||||
const { promisify } = require('util');
|
||||
const xml = promisify(require('xml2js').parseString);
|
||||
const { ANIMELIST_LOGIN } = process.env;
|
||||
|
||||
module.exports = class MangaCommand extends Command {
|
||||
@@ -30,7 +30,7 @@ module.exports = class MangaCommand extends Command {
|
||||
const { text } = await snekfetch
|
||||
.get(`https://${ANIMELIST_LOGIN}@myanimelist.net/api/manga/search.xml`)
|
||||
.query({ q: query });
|
||||
const { manga } = await xml.parseStringAsync(text);
|
||||
const { manga } = await xml(text);
|
||||
const synopsis = cleanXML(manga.entry[0].synopsis[0].substr(0, 2048));
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0x2D54A2)
|
||||
|
||||
Reference in New Issue
Block a user