From 1d6a3a44f7ad041a6837540e3b16b4bd55a933fb Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 8 Mar 2021 16:49:41 -0500 Subject: [PATCH] Replace deprecated url.parse --- commands/analyze/is-it-down.js | 4 ++-- commands/other/screenshot.js | 4 ++-- util/Util.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/analyze/is-it-down.js b/commands/analyze/is-it-down.js index 73fea3c5..845bea08 100644 --- a/commands/analyze/is-it-down.js +++ b/commands/analyze/is-it-down.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const url = require('url'); +const { URL } = require('url'); const validURL = require('valid-url'); module.exports = class IsItDownCommand extends Command { @@ -30,7 +30,7 @@ module.exports = class IsItDownCommand extends Command { } async run(msg, { site }) { - const parsed = url.parse(site); + const parsed = new URL(site); try { const { text } = await request .post('https://www.isitdownrightnow.com/check.php') diff --git a/commands/other/screenshot.js b/commands/other/screenshot.js index d99547b7..5c6c76f7 100644 --- a/commands/other/screenshot.js +++ b/commands/other/screenshot.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); -const url = require('url'); +const { URL } = require('url'); const validURL = require('valid-url'); module.exports = class ScreenshotCommand extends Command { @@ -32,7 +32,7 @@ module.exports = class ScreenshotCommand extends Command { async run(msg, { site }) { try { - const parsed = url.parse(site); + const parsed = new URL(site); if (!msg.channel.nsfw && this.client.adultSiteList.includes(parsed.host)) { return msg.reply('This site is NSFW.'); } diff --git a/util/Util.js b/util/Util.js index 62b6d70a..3cb876ea 100644 --- a/util/Util.js +++ b/util/Util.js @@ -1,7 +1,7 @@ const crypto = require('crypto'); const { decode: decodeHTML } = require('html-entities'); const { stripIndents } = require('common-tags'); -const url = require('url'); +const { URL } = require('url'); const { SUCCESS_EMOJI_ID } = process.env; const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea', 'ya', 'hai', 'si', 'sí', 'oui', 'はい', 'correct']; const no = ['no', 'n', 'nah', 'nope', 'nop', 'iie', 'いいえ', 'non', 'fuck off']; @@ -209,7 +209,7 @@ module.exports = class Util { const uris = str.match(/(https?:\/\/\S+)/g); if (!uris) return str; for (const uri of uris) { - const parsed = url.parse(uri); + const parsed = new URL(uri); if (!siteList.includes(parsed.host)) continue; str = str.replace(uri, text); }