mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
More accurate nsfw domain check
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { URL } = require('url');
|
||||
const { isImageNSFW } = require('../../util/Util');
|
||||
const { isImageNSFW, isUrlNSFW } = require('../../util/Util');
|
||||
|
||||
module.exports = class ScreenshotCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -36,18 +36,8 @@ module.exports = class ScreenshotCommand extends Command {
|
||||
async run(msg, { url }) {
|
||||
try {
|
||||
if (!msg.channel.nsfw) {
|
||||
let nsfw;
|
||||
if (this.client.adultSiteList.includes(url.host)) {
|
||||
nsfw = true;
|
||||
} else {
|
||||
try {
|
||||
const { url: newURL } = await request.get(url);
|
||||
const parsedNewURL = new URL(newURL);
|
||||
if (this.client.adultSiteList.includes(parsedNewURL.host)) nsfw = true;
|
||||
} catch {
|
||||
return msg.reply('This site did not respond, or sent an error.');
|
||||
}
|
||||
}
|
||||
const nsfw = await isUrlNSFW(url.href);
|
||||
if (nsfw === null) return msg.reply('This site did not respond, or sent an error.');
|
||||
if (nsfw) return msg.reply('This site is NSFW.');
|
||||
}
|
||||
const { body } = await request.get(`https://image.thum.io/get/width/1920/crop/675/noanimate/${url.href}`);
|
||||
|
||||
Reference in New Issue
Block a user