-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
94 lines (87 loc) · 2.81 KB
/
app.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
const Discord = require('discord.js')
const client = new Discord.Client()
let contents = []
let samechannelidcount = []
let channelidlist = []
function givemute(list, server){
let i = 0
while(list[i]){
server.members.cache.forEach((member) => {
if(member.id === list[i].id){
server.roles.cache.forEach((role) => {
if(role.name === "mute"){
member.edit({roles: null}).then(() => {
member.roles.add(role)
})
}
})
}
})
i++
}
}
function terrorproc(msg, msglist, server){
let i = 0
let userlist = []
while(msglist[i]){
if(userlist.includes(msglist[i].user)){
i++
continue
}else if(msglist[i].channelid != msg.channel.id){
i++
continue
}else{
server.members.cache.forEach((member) => {
if(msglist[i].user.id === member.id){
if(member.manageable){
userlist.push(msglist[i].user)
}
}
})
i++
}
}
if(userlist.length === 0){
console.log("only admin")
return
}
givemute(userlist, server)
i = 0
while(userlist[i]){
userlist[i].send("당신은 DFIC서버의 ``" + msg.channel.name + "`` 채널에서 서버 테러(여러명이서 도배)가 의심되는 구간에서 메시지를 보냈으므로 뮤트처리 되었습니다. 이의 있으시면 관리자에게 문의하세요.")
i++
}
i = 0
sendstring = ""
while(userlist[i]){
sendstring += "<@" + userlist[i].id + "> "
i++
}
sendstring += "언급된 사람들은 서버 테러(여러명이서 도배)가 의심되어 뮤트시켰습니다."
msg.channel.send(sendstring)
contents = []; samechannelidcount = []; channelidlist = []; useridlist = []
}
client.on('ready', () => {
console.log("ready")
})
client.on('message', (msg) => {
if(msg.channel.type == 'dm'){
return
}if(msg.channel.name === "반성의-방"){
return
}if(msg.author.bot && msg.author.id === "786901377087307776"){
return
}if(msg.channel.name === "반성의-방"){
return
}
let server = msg.guild
let user = msg.author
contents.push({user: user, content: msg.content, channelid: msg.channel.id})
channelidlist.push(msg.channel.id)
samechannelidcount = channelidlist.reduce((t, a) => { t[a] = (t[a] || 0)+1; return t }, {})
if(samechannelidcount[msg.channel.id] >= 16){
terrorproc(msg, contents, server)
}
})
setInterval(() => {contents = []; samechannelidcount = []; channelidlist = []; useridlist = []}, 10000)
client.login(process.env.token)