This repository has been archived by the owner on Jan 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathntest.js
65 lines (44 loc) · 1.49 KB
/
ntest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const Discord = require('discord.js');
const tools = require('../tools');
const request = require('request')
const cheerio = require('cheerio')
module.exports = {
name: 'ns',
aliases: [''],
description: 'ns',
usage: 'ns',
nsfw: false,
image: false,
args: false,
guildOnly: false,
ownerOnly: false,
async execute(message, args, request, cheerio) {
try {
function image(message) {
var options = {
url: "http://results.dogpile.com/serp?qc=images&q=" + "nsfw",
method: "GET",
headers: {
"Accept": "text/html",
"User-Agent": "Chrome"
}
};
request(options, function(error, response, responseBody) {
if(error) {
return
}
$ = cheerio.load(responseBody);
var links = $(".image a.link");
var urls = new Array(links.length).fill(0).map((v, i) => links.eq(i).attr("href"));
console.log(urls);
if(!urls.length) {
return
}
message.channel.send( urls[Math.floor(Math.random() * urls.length)]);
});
}
} catch (err) {
return tools.errorMessage(message, err);
}
},
};