mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
Will You Press the Button? and Word Commands
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = class WillYouPressTheButtonCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'will-you-press-the-button',
|
||||
aliases: ['press-the-button', 'button', 'wyptb', 'press-button'],
|
||||
group: 'random-res',
|
||||
memberName: 'will-you-press-the-button',
|
||||
description: 'Responds with a random "Will You Press The Button?" dilemma.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Will You Press The Button?',
|
||||
url: 'https://willyoupressthebutton.com/',
|
||||
reason: 'Dilemma Data'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { text } = await request.get('https://willyoupressthebutton.com/');
|
||||
const $ = cheerio.load(text, { normalizeWhitespace: true });
|
||||
const cond = $('div[id="cond"]').first().text().trim();
|
||||
const res = $('div[id="res"]').first().text().trim();
|
||||
return msg.say(`**${cond}** but **${res}**`);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const words = require('../../assets/json/word-list');
|
||||
|
||||
module.exports = class WordCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'word',
|
||||
aliases: ['random-word'],
|
||||
group: 'random-res',
|
||||
memberName: 'word',
|
||||
description: 'Responds with a random word.',
|
||||
credit: [
|
||||
{
|
||||
name: 'Grady Ward',
|
||||
url: 'https://en.wikipedia.org/wiki/Grady_Ward',
|
||||
reason: 'Moby Word Lists',
|
||||
reasonURL: 'http://www.gutenberg.org/ebooks/3201'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const word = words[Math.floor(Math.random() * words.length)];
|
||||
return msg.reply(word.toLowerCase());
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user