This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
118 lines (109 loc) · 3.11 KB
/
bot.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var pr0 = require('./pr0.js');
const Discord = require('discord.js');
var client = new Discord.Client();
const config= require('./config.json');
client.on('ready',() => {
console.log(`Bot has started, with ${client.users.size} users, in ${client.channels.size} channels of ${client.guilds.size} guilds.`);
client.user.setActivity('Browsing /top/');
});
client.on("guildCreate", guild => {
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
})
client.on("guildDelete", guild => {
console.log(`Deleted from guild: ${guild.name} (id: ${guild.id}).`);
})
client.on('message', async message => {
// Ignore bot messages
if (message.author.bot) return;
if (!message.content.startsWith("http")) return;
if (!message.content.match(/\bpr0gramm.com\/new/)) return;
// Do magic things
var id = pr0.cutId(message.content);
var post = pr0.postObject(id);
// Check if post is nsfw or nsfl to deactivate image preview
// nsfl
if (post.flags == 2 || post.flags == 3) {
message.channel.send("<https://img.pr0gramm.com/" + post.image + ">");
message.channel.send({
embed: {
color: 3447003,
author: {
name: post.author
},
title: post.id,
url: message.content,
fields: [
{
name: "Benis (+/-)",
value: post.up - post.down + ' (' + post.up + " / " + post.down + ')'
},
/* {
name: "top tags",
value: post.tags.first+ " " + post.tags.second + " " + post.tags.thrid
}*/
],
footer: {
color: 00000,
text: "Hochgeladen von " + post.user
}
},
})
// nswf
} else if (post.image.match(/\w\w\d+$/)) {
message.channel.send("<https://img.pr0gramm.com/" + post.image+ ">");
message.channel.send({
embed: {
color: 3447003,
author: {
name: post.author
},
title: post.id,
url: message.content,
fields: [
{
name: "Benis (+/-)",
value: post.up - post.down + ' (' + post.up + " / " + post.down + ')'
},
/* {
name: "top tags",
value: post.tags.first+ " " + post.tags.second + " " + post.tags.thrid
} */
],
footer: {
color: 00000,
text: "Hochgeladen von " + post.user
}
},
})
// sfw
} else {
message.channel.send({
embed: {
color: 3447003,
author: {
name: post.author
},
title: post.id,
url: message.content,
fields: [
{
name: "Benis (+/-)",
value: post.up - post.down + ' (' + post.up + " / " + post.down + ')'
},
/* {
name: "top tags",
value: post.tags.first+ " " + post.tags.second + " " + post.tags.thrid
}*/
],
footer: {
color: 00000,
text: "Hochgeladen von " + post.user
}
},
files: [
"https://img.pr0gramm.com/" + post.image
]
})
}
});
client.login(config.token);