mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 08:12:04 +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!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -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.';
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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, '-'))
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "35.0.0",
|
||||
"version": "35.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user