This repository has been archived by the owner on Feb 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
391 lines (357 loc) · 19 KB
/
main.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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
// Response for Uptime Robot
const http = require("http");
http
.createServer(function(request, response) {
response.writeHead(200, { "Content-Type": "text/plain" });
response.end("Discord bot is active now \n");
})
.listen(3000);
const fs = require('fs');
const json = JSON.parse(fs.readFileSync('./guild-info.json', 'utf8'));
// Discord bot implements
const discord = require("discord.js");
const client = new discord.Client();
var letter = [":zero:",":one:",":two:",":three:",":four:",":five:",":six:",":seven:",":eight:",":nine:",":keycap_ten:",":regional_indicator_a:",":regional_indicator_b:",":regional_indicator_c:",":regional_indicator_d:",":regional_indicator_e:",":regional_indicator_f:",":regional_indicator_g:",":regional_indicator_h:",":regional_indicator_i:",":regional_indicator_j:",":regional_indicator_k:",":regional_indicator_l:",":regional_indicator_m:",":regional_indicator_n:",":regional_indicator_o:",":regional_indicator_p:",":regional_indicator_q:",":regional_indicator_r:",":regional_indicator_s:",":regional_indicator_t:",":regional_indicator_u:",":regional_indicator_v:",":regional_indicator_w:",":regional_indicator_x:",":regional_indicator_y:",":regional_indicator_z:"]
var sign = ["0⃣","1⃣","2⃣","3⃣","4⃣","5⃣","6⃣","7⃣","8⃣","9⃣","🔟","🇦","🇧","🇨","🇩","🇪","🇫","🇬","🇭","🇮","🇯","🇰","🇱","🇲","🇳","🇴","🇵","🇶","🇷","🇸","🇹","🇺","🇻","🇼","🇽","🇾","🇿"]
client.on("ready", message => {
console.log("bot is ready!");
client.user.setActivity('ゲーム・コンパスランクロール付与中!', { type: 'PLAYING' })
client.channels.cache.get(json[0].Yaminabe.OperationChannel.Gamerole).messages.fetch(json[0].Yaminabe.MessageId.GamerolePanel);
client.channels.cache.get(json[0].Yaminabe.OperationChannel.Compass).messages.fetch(json[0].Yaminabe.MessageId.CompassPanel);
});
client.on("message", async message => {
//kick system
if (message.content.startsWith("//kick")) {
if (!(message.channel.id === json[0].Yaminabe.OperationChannel.BotPanel)) return message.delete();
if (!message.member.roles.cache.get(json[0].Yaminabe.Roles.Nabe))
return await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "実行する権限がありません。",
color: json[0].Yaminabe.Color.failed,
"footer": {
"text": "闇鍋bot",
"icon_url": "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
if (message.mentions.members.size !== 1)
return await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "kickするメンバーを1人指定してください",
color: json[0].Yaminabe.Color.failed,
"footer": {
"text": "闇鍋bot",
"icon_url": "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
var reason;
if (message.content.endsWith("1")){
reason = [
json[0].Yaminabe.KickReason.NoSelfIntoroduction.inside,
json[0].Yaminabe.KickReason.NoSelfIntoroduction.outside
];}
else if (message.content.endsWith("2")){
reason = [
json[0].Yaminabe.KickReason.order.inside,
json[0].Yaminabe.KickReason.order.outside
];
}
else if (message.content.endsWith("3")){
reason = [
json[0].Yaminabe.KickReason.other.inside,
json[0].Yaminabe.KickReason.other.outside
];}else return await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "正しい理由選択番号を入力してください。",
color: json[0].Yaminabe.Color.failed,
footer: {
"text": "闇鍋bot",
"icon_url": "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
const member = await message.mentions.members.first();
const text ={
embed: {
author: {
name: message.author.username,
icon_url: message.author.defaultAvatarURL
},
title: "Kicked User",
description:
`${member.user.tag}をkickしました` + "\nreason : " + reason[0] +"\n執行者 : " + message.member.user.username,
color: json[0].Yaminabe.Color.kick,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
};
try{
member.send({
embed: {
title: "kickされました。",
description:
"闇鍋サーバーにご参加いただきありがとうございます。\n\n" +
reason[1] +
"\n\n再度参加を希望される場合は、公式ホームページからお入りください。\nTeam鍋 Discordサーバー 「闇鍋」 運営一同 ",
color: json[0].Yaminabe.Color.info,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date(),
thumbnail: {
url:
"https://cdn.discordapp.com/icons/485736439527505922/d5fb962d62a0db6bc78d95a19a69f67b.png"
}
}
});
await message.channel.send(text);
await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.log).send(text);
member.kick(reason[0]);
}catch(e){console.log("kick system error\n"+e);};
};
//ban system
if (message.content.startsWith("//ban")) {
if (!(message.channel.id === json[0].Yaminabe.OperationChannel.BotPanel)) return message.delete();
if (!message.member.roles.cache.get(json[0].Yaminabe.Roles.Owner))
return await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "実行する権限がありません。",
color: json[0].Yaminabe.Color.failed,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
if (message.mentions.members.size !== 1)
return await message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "banするメンバーを1人指定してください",
color: json[0].Yaminabe.Color.failed,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
var reason;
if (message.content.endsWith("1")){
reason = [
json[0].Yaminabe.BanReason.order.inside,
json[0].Yaminabe.BanReason.order.outside
];}else return message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.BotPanel).send({
embed: {
title: "正しい理由選択番号を入力してください。",
color: json[0].Yaminabe.Color.failed,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
const member = await message.mentions.members.first();
const text = {
embed: {
author: {
name: message.author.username,
icon_url: message.author.defaultAvatarURL
},
title: "Banned User",
description:
`${member.user.tag}をbanしました` + "\nreason : " + reason[0] +"\n執行者 : " + message.member.user.username,
color: json[0].Yaminabe.Color.ban,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
};
try{
message.mentions.members.first().send({
embed: {
title: "Banされました。",
description:
"闇鍋サーバーにご参加いただきありがとうございます。\n\n" +
reason[1] +
"\n\nBanの解除等の申請はできません。運営が独自で判断します。\nTeam鍋 Discordサーバー 「闇鍋」 運営一同 ",
color: json[0].Yaminabe.Color.info,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date(),
thumbnail: {
url:
"https://cdn.discordapp.com/icons/485736439527505922/d5fb962d62a0db6bc78d95a19a69f67b.png"
}
}
});
message.channel.send(text);
message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.log).send(text);
member.ban(reason[0]);
}catch(e){console.log("ban system error\n"+e)}
};
//owner role give system
if (message.content.startsWith("//owner")) {
if (!(message.channel.id === json[0].Yaminabe.OperationChannel.Emergency)) return message.delete();
if (!message.content.endsWith(process.env.password)) return message.delete();
message.member.roles.add(json[0].Yaminabe.Roles.Owner);
message.delete();
message.guild.channels.cache.get(json[0].Yaminabe.OperationChannel.Emergency).send({
embed: {
title: "succeeded",
color: json[0].Yaminabe.Color.succeeded,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
};
//make or reload the role panel
if(message.content.startsWith("//reloadpanel")){
if((message.channel.id === json[0].Yaminabe.OperationChannel.Gamerole)){
if(!message.member.roles.cache.get(json[0].Yaminabe.Roles.Admin))
return message.channel.send({
embed: {
title: "実行する権限がありません。",
color: json[0].Yaminabe.Color.failed,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
var msg = await client.channels.cache.get(json[0].Yaminabe.OperationChannel.Gamerole).messages.fetch(json[0].Yaminabe.MessageId.GamerolePanel)
var text =("**ゲームロール**\nリアクションを押すことで役職が付きます。\n" + letter[0] +" : " +json[0].Yaminabe.Gamerole[0][0]+"\n");
msg.react(sign[0]);
for(var i=1; i<json[0].Yaminabe.Gamerole.length; i++){
text = (text + letter[i] +" : " +json[0].Yaminabe.Gamerole[i][0]+"\n");
msg.react(sign[i]);
};
msg.edit(text);
message.delete();
};
if((message.channel.id === json[0].Yaminabe.OperationChannel.Compass)){
if(!message.member.roles.cache.get(json[0].Yaminabe.Roles.Admin))
return message.channel.send({
embed: {
title: "実行する権限がありません。",
color: json[0].Yaminabe.Color.failed,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
timestamp: new Date()
}
});
var msg = await client.channels.cache.get(json[0].Yaminabe.OperationChannel.Compass).messages.fetch(json[0].Yaminabe.MessageId.CompassPanel)
var text =("**コンパスランク**\nリアクションを押すことで役職が付きます。\n" + letter[0] +" : " +json[0].Yaminabe.CompassRank[0][0]+"\n");
msg.react(sign[0]);
for(var i=1; i<json[0].Yaminabe.CompassRank.length; i++){
text = (text + letter[i] +" : " +json[0].Yaminabe.CompassRank[i][0]+"\n");
msg.react(sign[i]);
};
msg.edit(text);
message.delete();
}
};
if(message.content.startsWith("//send")){
message.channel.send("test");
await message.react(sign[20])
}
if(message.content.startsWith("//sent")){
console.log(message.member.user)
}
});
client.on("messageReactionAdd", async(messageReaction ,user) =>{
if(user.bot) return;
if((messageReaction.message.channel.id === json[0].Yaminabe.OperationChannel.Compass)){
for(var i=0;i<36;i++){
if(messageReaction.emoji.name === sign[i]){
var member = user.id
await client.guilds.cache.get(json[0].Yaminabe.Server).members.cache.get(member).roles.add(json[0].Yaminabe.CompassRank[i][1])
i=36
const reply = await messageReaction.message.channel.send({
embed: {
description: "コンパスランクの付与に成功しました。",
"footer": {
"text": "闇鍋bot",
"icon_url": "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
color: json[0].Yaminabe.Color.succeeded,
}
});
reply.delete({ timeout: 5000 });
};
};
};
if((messageReaction.message.channel.id === json[0].Yaminabe.OperationChannel.Gamerole)){
for(var i=0;i<36;i++){
if(messageReaction.emoji.name === sign[i]){
var member = user.id
await client.guilds.cache.get(json[0].Yaminabe.Server).members.cache.get(member).roles.add(json[0].Yaminabe.Gamerole[i][1])
i=36
const reply = await messageReaction.message.channel.send({
embed: {
description: "ゲームロールの付与に成功しました。",
color: json[0].Yaminabe.Color.succeeded,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
}
});
reply.delete({ timeout: 5000 });
};
};
};
});
client.on("messageReactionRemove", async(messageReaction ,user) =>{
if(user.bot) return;
if((messageReaction.message.channel.id === json[0].Yaminabe.OperationChannel.Compass)){
for(var i=0;i<36;i++)
if(messageReaction.emoji.name === sign[i]){
var member = user.id
await client.guilds.cache.get(json[0].Yaminabe.Server).members.cache.get(member).roles.remove(json[0].Yaminabe.CompassRank[i][1])
i=36
const reply = await messageReaction.message.channel.send({
embed: {
description: "コンパスランクの削除に成功しました。",
color: json[0].Yaminabe.Color.succeeded,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
}
});
reply.delete({ timeout: 5000 });
};
};
if((messageReaction.message.channel.id === json[0].Yaminabe.OperationChannel.Gamerole)){
for(var i=0;i<36;i++)
if(messageReaction.emoji.name === sign[i]){
var member = user.id
await client.guilds.cache.get(json[0].Yaminabe.Server).members.cache.get(member).roles.remove(json[0].Yaminabe.Gamerole[i][1])
i=36
const reply = await messageReaction.message.channel.send({
embed: {
description: "ゲームロールの削除に成功しました。",
color: json[0].Yaminabe.Color.succeeded,
footer: {
text: "闇鍋bot",
icon_url: "https://cdn.discordapp.com/avatars/718662724732715019/725fafaf9c00b459c74793651a51460b.png"},
}
});
reply.delete({ timeout: 5000 });
};
};
});
//new visitor announce
client.on('guildMemberAdd', member => {
const text = ("<@"+member.id+"> さん、 team鍋公式Discordサーバー「闇鍋」にご参加いただきありがとうございます!!\n当サーバーに参加後、<#"+ json[0].Yaminabe.Channels[1] +">・<#"+ json[0].Yaminabe.Channels[2] +">をお読みください。\nその後、<#"+ json[0].Yaminabe.Channels[3] +">に自己紹介をお願いします。\n自己紹介が運営に確認され次第、ほかのコンテンツが使用可能になります。")
member.guild.channels.cache.get(json[0].Yaminabe.Channels[0]).send(text);
});
if (process.env.DISCORD_BOT_TOKEN == undefined) {
console.log("please set ENV: DISCORD_BOT_TOKEN");
process.exit(0);
}
client.login(process.env.DISCORD_BOT_TOKEN);