-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.js
More file actions
111 lines (93 loc) · 4.24 KB
/
bot.js
File metadata and controls
111 lines (93 loc) · 4.24 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
global.Discord = require('discord.js');
myIntents = new Discord.Intents(32767)
flg = Discord.Intents.FLAGS
myIntents.remove(flg.GUILD_MESSAGE_TYPING, flg.DIRECT_MESSAGE_TYPING, flg.DIRECT_MESSAGE_REACTIONS)
global.client = new Discord.Client({intents : myIntents}); //.remove(['DIRECT_MESSAGE_TYPING', 'GUILD_MESSAGE_TYPING'])
global.DB = new (require('sync-mysql'))({
host : process.env.CLEARDB_HOST,
user : process.env.CLEARDB_USER,
password : process.env.CLEARDB_PASSWORD,
charset : 'utf8mb4',
database : process.env.CLEARDB_DATABASE
});
global.fs = require('fs');
global.disbut = require('discord-buttons');
global.retardMode = true;
global.predict_name = '';
disbut(client);
client.on('ready', msg => {
global.guild = client.guilds.cache.get('433242520034738186');
global.everyone = guild.roles.cache.get('433242520034738186');
fs.readdirSync('./functions/').forEach(file => {
global[file.split('.')[0]] = require('./functions/' + file);
});
global.commands = require('./commands');
client.user.setActivity('i!help', { type: 'LISTENING' });
log.start('== Bot ready ==');
});
client.on('message', async msg => {
// Проверка на канал и наличие префикса
if(msg.author.id == client.user.id) return;
if(msg.channel.type == 'dm') return send.error(msg, 'Лс для пидоров');
if(msg.channel.guild.id != '433242520034738186') return;
if(msg.content.substr(0, process.env.PREFIX.length) != process.env.PREFIX){
// await reaction.rule(msg)
// if(retardMode){
// await reaction.suggestion2(msg)
// } else {
// await reaction.suggestion1(msg)
// }
// //reaction.suggestion3(msg)
// if(msg.channel.id == 681790010550255617) await reaction.nsfw(msg) // Анализатор ссылок в nsfw
// if(msg.channel.id == 500300930466709515) await reaction.opinion(msg); // Реакции в #предложения
// if(msg.channel.id == 572472723624951839) await reaction.event(msg); // Реакции в #ивенты
// if(msg.channel.id == 612280548777525249) await reaction.elections(msg); // Реакции в #выборы
// if(commands.list.phishing) return commands.list.phishing.message(msg);
return;
}
if(msg.author.bot) return;
const content = msg.content.substr(process.env.PREFIX.length).split(/\s+/);
const command = commands.get(content.shift().toLowerCase());
if(!command || command.onlySlash) return;
await msg.channel.send({ content : 'Все модули бота поддерживают слеш команды.\nПопробуйте пользоваться слэш командами в течении какого нибудь времени чтобы привыкнуть к ним.\nВ апреле 2022 большинство ботов перейдёт на такой тип взаимодействия, вы к этому уже будете готовы' })
log.info(member2name(msg.member, 1, 1), 'used', msg.content);
await command.call(msg, content);
});
//Обработка INTERACTION_CREATE
client.on('raw', async response => {
if(response.t != "INTERACTION_CREATE") return;
if(response.d.type == 2) {
const command = commands.get(response.d.data.name.toLowerCase());
if(!command)
return interactionRespond.send(response.d, {
content : 'Команда не найдена',
flags : 64
}, 'error');
log.info(member2name(response.d.member, 1, 1), 'used', '/' + response.d.data.name);
if(response.d.data.type == 2 || response.d.data.type == 3)
await command.context(response.d);
else if(response.d.data.type == 1)
await command.slash(response.d);
} else if(response.d.type == 4){
const command = commands.get(response.d.data.name.toLowerCase());
if(!command) return;
await command.predict(response.d)
} else if(response.d.type == 3){
if(response.d.data.component_type != 2) return;
const param = response.d.data.custom_id.split('|');
if(!param.length) return;
if(param[0] == 'dismiss'){
await reaction.button1(response.d, param)
}
if(param[0] == 'deleteOriginal'){
await reaction.button2(response.d, param)
}
if(param[0] == 'correct'){
await reaction.button3(response.d, param)
}
const command = commands.get(param[0]);
if(!command) return;
command.button(response.d, param);
}
});
client.login(process.env.TOKEN);