Check URL down more accurately

This commit is contained in:
Dragon Fire
2021-03-08 16:45:13 -05:00
parent 9a8d084bb4
commit 1686732c57
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -1,5 +1,7 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const url = require('url');
const validURL = require('valid-url');
module.exports = class IsItDownCommand extends Command {
constructor(client) {
@@ -20,17 +22,19 @@ module.exports = class IsItDownCommand extends Command {
{
key: 'url',
prompt: 'What URL do you want to test?',
type: 'string'
type: 'string',
validate: site => Boolean(validURL.isWebUri(site))
}
]
});
}
async run(msg, { url }) {
const parsed = url.parse(site);
try {
const { text } = await request
.post('https://www.isitdownrightnow.com/check.php')
.query({ domain: url });
.query({ domain: parsed.host });
const down = text.includes('div class="statusdown"');
if (!down) return msg.reply('👍 This site is up and running.');
return msg.reply('👎 Looks like this site is down for everyone...');
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "131.11.1",
"version": "131.11.2",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {