mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 21:40:51 +02:00
spoopy link command
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class SpoopyLinkCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'spoopy-link',
|
||||
group: 'random',
|
||||
memberName: 'spoopy-link',
|
||||
description: 'Checks if a link is spoopy or not.',
|
||||
args: [
|
||||
{
|
||||
key: 'site',
|
||||
prompt: 'What site do you think is spoopy?',
|
||||
type: 'string',
|
||||
parse: query => encodeURIComponent(query)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { site } = args;
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get(`https://spoopy.link/api/${site}`);
|
||||
return msg.say(stripIndents`
|
||||
${body.safe ? 'This site is safe!' : 'This site may not be safe...'}
|
||||
${body.chain.map(url => `<${url.url}> [${url.safe ? 'SAFE' : `UNSAFE: ${url.reasons.join(', ')}`}]`).join('\n')}
|
||||
`);
|
||||
} catch (err) {
|
||||
return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user