-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.go
40 lines (33 loc) · 848 Bytes
/
util.go
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
package dream
import (
"strconv"
"time"
"github.com/bwmarrin/discordgo"
)
/*
Util provides various utility functions
*/
// StatusColor returns the colour associated with an online status
func StatusColor(status discordgo.Status) int {
color := 0
switch status {
case discordgo.StatusDoNotDisturb:
color = 0xff0000
case discordgo.StatusOnline:
color = 0x00ff00
case discordgo.StatusIdle:
color = 0xffff00
}
return color
}
// CreationTime returns the creation time of a Snowflake ID relative to the creation of Discord.
// Taken from https://github.com/Moonlington/FloSelfbot/blob/master/commands/commandutils.go#L117
func CreationTime(ID string) (t time.Time, err error) {
i, err := strconv.ParseInt(ID, 10, 64)
if err != nil {
return
}
timestamp := (i >> 22) + 1420070400000
t = time.Unix(timestamp/1000, 0)
return
}