spoopy link command

This commit is contained in:
Daniel Odendahl Jr
2017-09-02 18:21:03 +00:00
parent 358c956ef9
commit 787f3ec54a
7 changed files with 48 additions and 8 deletions
+36
View File
@@ -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!`);
}
}
};
+2 -2
View File
@@ -17,8 +17,8 @@ module.exports = class DiscrimCommand extends Command {
type: 'string',
default: '',
validate: discrim => {
if (/[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
return 'Invalid Discriminator.';
if (/^[0-9]+$/g.test(discrim) && discrim.length === 4) return true;
return 'Invalid discriminator.';
}
}
]
+4 -2
View File
@@ -15,12 +15,14 @@ module.exports = class GitHubCommand extends Command {
{
key: 'author',
prompt: 'Who is the author of the repository?',
type: 'string'
type: 'string',
parse: author => encodeURIComponent(author)
},
{
key: 'repository',
prompt: 'What is the name of the repository?',
type: 'string'
type: 'string',
parse: repository => encodeURIComponent(repository)
}
]
});
+1 -1
View File
@@ -18,7 +18,7 @@ module.exports = class PokedexCommand extends Command {
key: 'pokemon',
prompt: 'What Pokémon would you like to get information on?',
type: 'string',
parse: pokemon => pokemon.toLowerCase().replace(/ /g, '-')
parse: pokemon => encodeURIComponent(pokemon.toLowerCase().replace(/ /g, '-'))
}
]
});
+2 -1
View File
@@ -14,7 +14,8 @@ module.exports = class RedditCommand extends Command {
{
key: 'subreddit',
prompt: 'What subreddit would you like to get a post from?',
type: 'string'
type: 'string',
parse: subreddit => encodeURIComponent(subreddit)
}
]
});
+2 -1
View File
@@ -16,7 +16,8 @@ module.exports = class WikiaCommand extends Command {
{
key: 'wiki',
prompt: 'What is the subdomain of the wiki you want to search?',
type: 'string'
type: 'string',
parse: wiki => encodeURIComponent(wiki)
},
{
key: 'query',
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "35.0.0",
"version": "35.1.0",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {