-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
86 lines (73 loc) · 2.75 KB
/
index.js
File metadata and controls
86 lines (73 loc) · 2.75 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
const Discord = require("discord.js");
const botConfig = require("./botConfig.json");
const findNextLesson = require("./utils/findNextLesson.js");
const {parseSchedule, parseScheduleTeacher} = require("./utils/parseSchedule.js");
const discordClient = new Discord.Client();
const commandPrefix = "!";
const getMessage = (lessons, isTeacher) => {
const nextLesson = findNextLesson(lessons);
if (nextLesson) {
return nextLessonMessage = `
Предмет: ${nextLesson.type} ${nextLesson.subject},
Дата: ${nextLesson.startsAt.year}.${nextLesson.startsAt.month}.${nextLesson.startsAt.day},
Время: ${nextLesson.time.start}-${nextLesson.time.end}
Аудитория: ${nextLesson.audiences[0].name}
${isTeacher ? `Группы: ${nextLesson.groups.join(", ")}` : `Преподаватель: ${nextLesson.teachers[0].name}`}
`;
} else {
return "Ближайших пар нет";
}
}
discordClient.on("message", async (msg) => {
if (msg.author.bot) return;
const channelId = msg.channel.id;
const channel = discordClient.channels.cache.get(channelId);
if (msg.content.startsWith(commandPrefix)) {
const splitted = msg.content.split(" ")
if (splitted.length === 0){
channel.send("Пустой текст команды");
return;
}
switch(splitted[0].slice(1)) {
case 'новая-пара': {
if (splitted.length > 1){
const lessons = parseSchedule(splitted[1]);
const message = getMessage(lessons, false);
channel.send(message);
} else {
channel.send("Неверный формат необходимо указать группу в формате курс-группа, например 1-42");
}
break;
}
case 'Сенсей': {
if (splitted.length > 1){
const lessons = parseScheduleTeacher(`${splitted[1]} ${splitted[2]}`);
const message = getMessage(lessons, true);
channel.send(message);
} else {
channel.send("Неверный формат необходимо указать Фамилия И.О.");
}
break;
}
case 'gav': {
if (splitted.length > 1){
channel.send(`${msg.author.username} ${msg.author.tag}`);
const n = + splitted[1];
if (n) {
for (let i =0 ; i < n; i++){
channel.send(`Gav`);
}
channel.send(`Мокеволеч лыб ешьнар я`);
channel.send(`Меня%;*:№""№"!`);
channel.send(`@@@#$Я__:;`);
channel.send(`Isuct - lier`);
}
} else {
channel.send(`RRRRRRR`)
}
break;
}
}
}
});
discordClient.login(botConfig.token);