-
Notifications
You must be signed in to change notification settings - Fork 2
/
util.js
56 lines (50 loc) · 1.44 KB
/
util.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
require("dotenv").config();
const prefix = process.env["COMMAND_PREFIX"];
const discord = {
/**
* Gets the current number of Online Users on the server.
* @param users A Collection of all users
* @returns The number of online users
*/
getOnlineUsers: users =>
users.filter(user => user.presence.status !== "offline" && !user.bot).size,
/**
* Gets the first command from the message that was sent.
* @param message A message object
* @return The command that was issued
*/
getCommand: message => {
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
return args.shift().toLowerCase();
},
/**
* Gets the total number of voice channels in the server.
* @param channels A collection of server channels
* @return The number of voice channels
*/
getVoiceChannels: channels =>
channels.filter(channel => channel.type === "voice").size,
/**
* Gets the number of text channels in the server.
* @param channels A collection of server channels
* @return The number of text channels
*/
getTextChannels: channels =>
channels.filter(channel => channel.type === "text").size
};
const helpers = {
/**
* A simple function for converting the timestamp to a
* readable format.
* @param time A Discord timestamp
* @return A string of the Date and Time
*/
convertTime: time => new Date(time).toString()
};
module.exports = {
discord,
helpers
};