From 8c934958c6476b3b54f438314e739df0b866cf96 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 7 Mar 2021 17:10:12 -0500 Subject: [PATCH] Is It Down Command --- README.md | 5 ++++- commands/analyze/is-it-down.js | 41 ++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 commands/analyze/is-it-down.js diff --git a/README.md b/README.md index 69d8f1de..f1ece183 100644 --- a/README.md +++ b/README.md @@ -265,7 +265,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 615 +Total: 616 ### Utility: @@ -574,6 +574,7 @@ Total: 615 * **gender:** Determines the gender of a name. * **has-transparency:** Determines if an image has transparency in it. * **image-size:** Determines the size of an image. +* **is-it-down:** Determines if a website is down or not. * **ocr:** Performs Optical Character Recognition on an image. * **parse-time:** Analyzes the time duration you provide and gives the result. * **read-qr-code:** Reads a QR Code. @@ -1403,6 +1404,8 @@ here. * mindfulness (API) - [ipify API](https://www.ipify.org/) * ip (API) +- [Is It Down Right Now?](https://www.isitdownrightnow.com/) + * is-it-down (API) - [iStock](https://www.istockphoto.com/) * car-race ([Background Image](https://www.istockphoto.com/vector/side-view-of-a-road-with-a-crash-barrier-roadside-green-meadow-and-clear-blue-sky-gm1081596948-290039955)) - [Jack The Awesomeness Gamer](https://www.youtube.com/channel/UCIeA23B91hAeR1UuC2VDSdQ) diff --git a/commands/analyze/is-it-down.js b/commands/analyze/is-it-down.js new file mode 100644 index 00000000..69dd2d74 --- /dev/null +++ b/commands/analyze/is-it-down.js @@ -0,0 +1,41 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); + +module.exports = class IsItDownCommand extends Command { + constructor(client) { + super(client, { + name: 'is-it-down', + aliases: ['website-down', 'web-down', 'site-down', 'is-down'], + group: 'analyze', + memberName: 'is-it-down', + description: 'Determines if a website is down or not.', + credit: [ + { + name: 'Is It Down Right Now?', + url: 'https://www.isitdownrightnow.com/', + reason: 'API' + } + ], + args: [ + { + key: 'url', + prompt: 'What URL do you want to test?', + type: 'string' + } + ] + }); + } + + async run(msg, { url }) { + try { + const { text } = await request + .post('https://www.isitdownrightnow.com/check.php') + .query({ domain: url }); + 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...'); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 0bf6e544..a88bca7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "131.9.0", + "version": "131.10.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {