mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Random Person Command
This commit is contained in:
@@ -36,7 +36,7 @@ module.exports = class HistoryCommand extends Command {
|
|||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
.setDescription(`${event.year}: ${event.text}`)
|
.setDescription(`${event.year}: ${event.text}`)
|
||||||
.addField('❯ See More',
|
.addField('❯ See More',
|
||||||
event.links.map(link => `${link.title}: ${link.link.replace(/\)/g, '%29')}`).join('\n'));
|
event.links.map(link => `[${link.title}](${link.link.replace(/\)/g, '%29')})`).join(', '));
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.status === 404 || err.status === 500) return msg.say('Could not find any results.');
|
if (err.status === 404 || err.status === 500) return msg.say('Could not find any results.');
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module.exports = class NewYorkTimesCommand extends Command {
|
|||||||
async run(msg, { query }) {
|
async run(msg, { query }) {
|
||||||
try {
|
try {
|
||||||
const fetch = snekfetch
|
const fetch = snekfetch
|
||||||
.get(`https://api.nytimes.com/svc/search/v2/articlesearch.json`)
|
.get('https://api.nytimes.com/svc/search/v2/articlesearch.json')
|
||||||
.query({
|
.query({
|
||||||
'api-key': NYTIMES_KEY,
|
'api-key': NYTIMES_KEY,
|
||||||
sort: 'newest'
|
sort: 'newest'
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const snekfetch = require('snekfetch');
|
||||||
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { list } = require('../../structures/Util');
|
||||||
|
const genders = ['male', 'female', 'both'];
|
||||||
|
|
||||||
|
module.exports = class RandomPersonCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'random-person',
|
||||||
|
group: 'random-res',
|
||||||
|
memberName: 'random-person',
|
||||||
|
description: 'Responds with a randomly generated person.',
|
||||||
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'gender',
|
||||||
|
prompt: `What gender do you want to generate a name for? Either ${list(genders, 'or')}.`,
|
||||||
|
type: 'string',
|
||||||
|
default: 'both'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { gender }) {
|
||||||
|
try {
|
||||||
|
const { body } = await snekfetch
|
||||||
|
.get('https://randomuser.me/api/')
|
||||||
|
.query({
|
||||||
|
gender,
|
||||||
|
noinfo: ''
|
||||||
|
});
|
||||||
|
const data = body.results[0];
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setColor(0x9797FF)
|
||||||
|
.setThumbnail(data.picture.large)
|
||||||
|
.addField('❯ First Name',
|
||||||
|
data.name.first.toUpperCase(), true)
|
||||||
|
.addField('❯ Last Name',
|
||||||
|
data.name.last.toUpperCase(), true)
|
||||||
|
.addField('❯ Title',
|
||||||
|
data.name.title.toUpperCase(), true)
|
||||||
|
.addField('❯ Gender',
|
||||||
|
data.gender.toUpperCase(), true)
|
||||||
|
.addField('❯ Username',
|
||||||
|
data.login.username, true)
|
||||||
|
.addField('❯ Password',
|
||||||
|
data.login.password, true)
|
||||||
|
.addField('❯ Email',
|
||||||
|
data.email, true)
|
||||||
|
.addField('❯ Phone',
|
||||||
|
data.phone, true)
|
||||||
|
.addField('❯ Cell',
|
||||||
|
data.cell, true)
|
||||||
|
.addField('❯ Birthday',
|
||||||
|
new Date(data.dob).toDateString(), true)
|
||||||
|
.addField('❯ Address',
|
||||||
|
stripIndents`
|
||||||
|
${data.location.street.toUpperCase()}
|
||||||
|
${data.location.city.toUpperCase()}, ${data.location.state.toUpperCase()} ${data.location.postcode}
|
||||||
|
`);
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -23,7 +23,7 @@ module.exports = class ShortenURLCommand extends Command {
|
|||||||
async run(msg, { url }) {
|
async run(msg, { url }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await snekfetch
|
const { body } = await snekfetch
|
||||||
.post(`https://www.googleapis.com/urlshortener/v1/url`)
|
.post('https://www.googleapis.com/urlshortener/v1/url')
|
||||||
.query({ key: GOOGLE_KEY })
|
.query({ key: GOOGLE_KEY })
|
||||||
.send({ longUrl: url });
|
.send({ longUrl: url });
|
||||||
return msg.say(`<${body.id}>`);
|
return msg.say(`<${body.id}>`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "42.6.1",
|
"version": "42.7.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Database {
|
|||||||
)
|
)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error(`[DATABASE] Unable to connect: ${err}`);
|
console.error(`[DATABASE] Unable to connect: ${err}`);
|
||||||
console.error(`[DATABASE] Reconnecting in 5 seconds...`);
|
console.error('[DATABASE] Reconnecting in 5 seconds...');
|
||||||
setTimeout(() => Database.start(), 5000);
|
setTimeout(() => Database.start(), 5000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user