mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 22:34:46 +02:00
22.0.0
This commit is contained in:
@@ -13,12 +13,8 @@ module.exports = class CatCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('http://random.cat/meow');
|
||||
return msg.say(body.file);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.get('http://random.cat/meow');
|
||||
return msg.say(body.file);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -12,12 +12,8 @@ module.exports = class DogCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://random.dog/woof.json');
|
||||
return msg.say(body.url);
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
}
|
||||
const { body } = await snekfetch
|
||||
.get('https://random.dog/woof.json');
|
||||
return msg.say(body.url);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,7 +15,6 @@ module.exports = class XiaoCommand extends Command {
|
||||
|
||||
run(msg) {
|
||||
const xiao = Math.floor(Math.random() * 10) + 1;
|
||||
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] })
|
||||
.catch(err => msg.say(`${err.name}: ${err.message}`));
|
||||
return msg.say({ files: [path.join(__dirname, '..', '..', 'assets', 'images', `xiao${xiao}.png`)] });
|
||||
}
|
||||
};
|
||||
|
||||
+27
-28
@@ -16,11 +16,14 @@ module.exports = class XKCDCommand extends Command {
|
||||
key: 'type',
|
||||
prompt: 'Would you like to get the comic for today or random?',
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (['today', 'random'].includes(type.toLowerCase())) return true;
|
||||
return 'Please enter either `today` or `random`';
|
||||
},
|
||||
default: 'random'
|
||||
default: 'random',
|
||||
validate: (type) => {
|
||||
if (['today', 'random'].includes(type.toLowerCase())) {
|
||||
return true;
|
||||
} else {
|
||||
return 'Please enter either `today` or `random`';
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -28,29 +31,25 @@ module.exports = class XKCDCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { type } = args;
|
||||
try {
|
||||
const current = await snekfetch
|
||||
.get('https://xkcd.com/info.0.json');
|
||||
if (type === 'today') {
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${current.body.num} - ${current.body.title}`)
|
||||
.setURL(`https://xkcd.com/${current.body.num}`)
|
||||
.setImage(current.body.img)
|
||||
.setFooter(current.body.alt);
|
||||
return msg.embed(embed);
|
||||
} else {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await snekfetch
|
||||
.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
} catch (err) {
|
||||
return msg.say(`${err.name}: ${err.message}`);
|
||||
const current = await snekfetch
|
||||
.get('https://xkcd.com/info.0.json');
|
||||
if (type === 'today') {
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${current.body.num} - ${current.body.title}`)
|
||||
.setURL(`https://xkcd.com/${current.body.num}`)
|
||||
.setImage(current.body.img)
|
||||
.setFooter(current.body.alt);
|
||||
return msg.embed(embed);
|
||||
} else {
|
||||
const random = Math.floor(Math.random() * current.body.num) + 1;
|
||||
const { body } = await snekfetch
|
||||
.get(`https://xkcd.com/${random}/info.0.json`);
|
||||
const embed = new RichEmbed()
|
||||
.setTitle(`${body.num} - ${body.title}`)
|
||||
.setURL(`https://xkcd.com/${body.num}`)
|
||||
.setImage(body.img)
|
||||
.setFooter(body.alt);
|
||||
return msg.embed(embed);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user