-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathspam.js
More file actions
176 lines (175 loc) · 5.35 KB
/
spam.js
File metadata and controls
176 lines (175 loc) · 5.35 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
var Discord = require('discord.js');
var bot = new Discord.Client();
var config = require('./config.json');
var prefix = config.bot.prefix;
bot.on('message', msg => {
var suffix = msg.content.split(' ').slice(1);
//CMDS
if (msg.content.startsWith(prefix + "help")) {
var help = suffix[0];
if (!help) {
msg.channel.send([
'```js' +
'\nCOMMANDS:' +
`\n${prefix}spam` +
`\n${prefix}dspam` +
`\n${prefix}pmspam` +
`\n${prefix}dpmspam` +
`\n${prefix}cspam` +
'```'
])
} else {
if (help === "spam") {
msg.channel.send([
'```js\nSpams something you said.' +
`\n${prefix}spam | NUMBER | TO SPAM\`\`\``
])
} else
//PMSPAM
if (help === "pmspam") {
msg.channel.send([
'```js\nPM Spams someone.' +
`\n${prefix}pmspam | @USERNAME | NUMBER | TO SPAM\`\`\``
])
} else
//DSPAM
if (help === "dspam") {
msg.channel.send([
'```js\nSpams something you said, but then deletes.' +
`\n${prefix}dspam | NUMBER | TO SPAM\`\`\``
])
} else
//DPMSPAM
if (help === "dpmspam") {
msg.channel.send([
'```js\nSpams someone, then deletes messages.' +
`\n${prefix}dpmspam | @USERNAME | NUMBER | TOSPAM\`\`\``
])
} else
//CHANNEL SPAM
if (help === "cspam") {
msg.channel.send([
'```js\nSpams in a specific channel.' +
`\n${prefix}cspam | #CHANNEL | NUMBER | TOSPAM\`\`\``
])
}
}
} else
//SPAM
if (msg.content.startsWith(prefix + "spam")) {
try {
var timesRun = 0;
var numberspam = suffix[0];
console.log(numberspam)
var tospam = msg.content.split(' ').slice(2).join(' ');
console.log(tospam)
let messagecount = parseInt(numberspam) ? parseInt(numberspam) : 1;
var interval = setInterval(function() {
msg.channel.send(tospam)
timesRun += 1
if (timesRun === messagecount) {
clearInterval(interval)
}
}, 1)
msg.channel.send(interval.length);
} catch (err) {
console.log(err)
}
} else
//DELETESPAM
if (msg.content.startsWith(prefix + "dspam")) {
try {
var timesRun = 0;
var numberspam = suffix[0];
console.log(numberspam)
var tospam = msg.content.split(' ').slice(2).join(' ');
console.log(tospam)
let messagecount = parseInt(numberspam) ? parseInt(numberspam) : 1;
var interval = setInterval(function() {
msg.channel.send(tospam).then(m => {
m.delete()
});
timesRun += 1
if (timesRun === messagecount) {
clearInterval(interval)
}
}, 1)
msg.channel.send(interval.length);
} catch (err) {
console.log(err)
}
} else
//PM
if (msg.content.startsWith(prefix + "pmspam")) {
try {
var usertospam = msg.mentions.users.first();
var timesRun = 0;
var numberspam = suffix[1];
console.log(numberspam)
var tospam = msg.content.split(' ').slice(3).join(' ');
console.log(tospam)
let messagecount = parseInt(numberspam) ? parseInt(numberspam) : 1;
var interval = setInterval(function() {
usertospam.send(tospam)
timesRun += 1
if (timesRun === messagecount) {
clearInterval(interval)
}
}, 1)
usertospam.send(interval.length);
} catch (err) {
msg.channel.send("Error, user not found.")
}
} else
//PMDELETE
if (msg.content.startsWith(prefix + "dpmspam")) {
try {
var usertospam = msg.mentions.users.first();
var timesRun = 0;
var numberspam = suffix[1];
console.log(numberspam)
var tospam = msg.content.split(' ').slice(3).join(' ');
console.log(tospam)
let messagecount = parseInt(numberspam) ? parseInt(numberspam) : 1;
var interval = setInterval(function() {
usertospam.send(tospam).then(m => {
m.delete()
});
timesRun += 1
if (timesRun === messagecount) {
clearInterval(interval)
}
}, 1)
usertospam.send(interval.length);
} catch (err) {
msg.channel.send("Error, user not found.")
}
} else
//CHANNEL SPAM
if (msg.content.startsWith(prefix + "cspam")) {
try {
var channel = msg.mentions.channels.first();
var timesRun = 0;
var numberspam = suffix[1];
console.log(numberspam)
var tospam = msg.content.split(' ').slice(2).join(' ');
console.log(tospam)
let messagecount = parseInt(numberspam) ? parseInt(numberspam) : 1;
var interval = setInterval(function() {
bot.channels.get(channel.id).send(tospam);
timesRun += 1
if (timesRun === messagecount) {
clearInterval(interval)
}
}, 1)
bot.channels.get(channel.id).send(interval.length);
} catch(err) {
console.log(err)
}
}
});
bot.login(config.bot.token);
//UNHANDLED REJECTION
process.on("unhandledRejection", err => {
console.error("Uncaught Promise Error: \n" + err.stack);
});