-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
104 lines (94 loc) · 2.93 KB
/
index.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
require('dotenv').config();
const Discord = require('discord.js');
const bot = new Discord.Client();
const TOKEN = process.env.TOKEN;
bot.login(TOKEN);
const reaction_messages = {
cs_go: '843471254798991397',
valorant: '843471368347058176',
gta: '843471450887421992',
rocket_league: '843471554889515028',
rainbow_six_siege: '843471648443072572',
diger_oyunlar: '843471818094411776',
lol: '860591512307499018',
};
const roles = {
cs_go: '843441610519216139',
valorant: '835996317792337960',
gta: '835582651171733525',
rocket_league: '832737638468681779',
rainbow_six_siege: '843470778724253705',
diger_oyunlar: '843470734125826048',
lol: '860591105812594688',
};
const validate = require('./utils/validations');
bot.on('ready', async () => {
bot.user.setPresence({
status: "online",
game: {
name: 'with depression',
type: 'STREAMING',
url: 'https://www.twitch.tv/turalhj',
},
});
bot.channels.cache.get('843442306693595178').messages.fetch({ limit: 50 });
});
bot.on('messageReactionAdd', async (reaction, user) => {
if (Object.values(reaction_messages).includes(reaction.message.id)) {
if (reaction.emoji.name !== '✅') {
return reaction.remove();
}
const { guild } = reaction.message;
const member = guild.members.cache.find(member => member.id === user.id);
Object.keys(reaction_messages).forEach(game_name => {
if (reaction.message.id === reaction_messages[game_name]) {
const role = guild.roles.cache.find(
({ id }) => id === roles[game_name]
);
member.roles.add(role);
}
});
}
});
bot.on('messageReactionRemove', async (reaction, user) => {
if (Object.values(reaction_messages).includes(reaction.message.id)) {
if (reaction.emoji.name === '✅') {
const { guild } = reaction.message;
const member = guild.members.cache.find(member => member.id === user.id);
Object.keys(reaction_messages).forEach(game_name => {
if (reaction.message.id === reaction_messages[game_name]) {
const role = guild.roles.cache.find(
({ id }) => id === roles[game_name]
);
member.roles.remove(role);
}
});
}
}
});
bot.on('guildMemberAdd', async member => {
await member.roles
.add(member.guild.roles.cache.find(({ id }) => id === '877341884320735342'))
.then(() => {
member.guild.channels.cache
.find(channel => channel.id === '828807813526454284')
.send(`<@${member.id}> aramıza qatıldı. `);
});
});
/* Add log to aramizdan-ayrilanlar */
bot.on('guildMemberRemove', async member => {
member.guild.channels.cache
.find(channel => channel.id === '828808479534743582')
.send(` ${member.displayName} aramızdan ayrıldı.`);
});
bot.on('message', async msg => {
if (msg) {
const { isValid } = validate(msg);
if (!isValid) {
msg
.delete()
.then(() => {})
.catch(() => {});
}
}
});