-
Notifications
You must be signed in to change notification settings - Fork 75
/
time.js
32 lines (30 loc) · 1.13 KB
/
time.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
const { registerBotCommand } = require('../botEngine.js');
const command = {
regex: /(?<!\S)\/time(?!\S)/,
cb: async ({ mentions }) => {
let users = '';
const mentionedUsers = mentions.users.array();
if (mentionedUsers.length >= 3) {
mentionedUsers.forEach((user, index) => {
if (index < mentionedUsers.length - 1) {
users += ` ${user},`;
} else {
users += ` and ${user}`;
}
});
} else if (mentionedUsers.length === 2) {
mentionedUsers.forEach((user, index) => {
if (index < mentionedUsers.length - 1) {
users += ` ${user}`;
} else {
users += ` and ${user}`;
}
});
} else if (mentionedUsers.length === 1) {
users = `, ${mentionedUsers[0]}`;
}
return !users ? 'Time is an illusion. Please read this: https://discord.com/channels/505093832157691914/505093832157691916/765633002393829389' : `Time is an illusion${users}. Please read this: https://discord.com/channels/505093832157691914/505093832157691916/765633002393829389`;
},
};
registerBotCommand(command.regex, command.cb);
module.exports = command;