This repository has been archived by the owner on Sep 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
commandstatus.go
120 lines (98 loc) · 2.25 KB
/
commandstatus.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
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
112
113
114
115
116
117
118
119
120
package main
import (
"strings"
"github.com/diamondburned/discordgo"
)
func setStatus(input []string) {
if d.State.Settings == nil {
Message("Settings are uninitialized")
return
}
s := d.State.Settings.Status
if len(input) < 2 {
switch s {
case discordgo.StatusOnline:
Message("Status: Online")
case discordgo.StatusIdle:
Message("Status: Idle")
case discordgo.StatusDoNotDisturb:
Message("Status: Do not disturb")
case discordgo.StatusInvisible:
Message("Status: Invisible")
default:
Message(string(s))
}
return
}
switch strings.Join(input[1:], " ") {
case string(discordgo.StatusOnline), "Online":
s = discordgo.StatusOnline
case string(discordgo.StatusIdle), "Idle",
"Away", "away":
s = discordgo.StatusIdle
case string(discordgo.StatusDoNotDisturb),
"do not disturb", "Do not disturb", "Do Not Disturb",
"Busy", "busy":
s = discordgo.StatusDoNotDisturb
case string(discordgo.StatusInvisible), "invis", "Invisible":
s = discordgo.StatusInvisible
default:
Message("Unknown status to set, check description")
return
}
if _, err := d.UserUpdateStatus(s); err != nil {
Warn(err.Error())
return
}
Message("Set status to " + string(s))
}
func setListen(text []string) {
if len(text) < 2 {
Message("Missing string!")
return
}
s := strings.Join(text[1:], " ")
if err := d.UpdateListeningStatus(s); err != nil {
Message(err.Error())
} else {
Message("Set listening status to " + s)
}
}
func setGame(text []string) {
var s string
if len(text) > 1 {
s = strings.Join(text[1:], " ")
}
var (
msg string
gametype = discordgo.GameTypeGame
)
switch {
case strings.HasPrefix(strings.ToLower(s), "listening to "):
s = s[13:]
gametype = discordgo.GameTypeListening
msg = "Set listening to "
case strings.HasPrefix(strings.ToLower(s), "watching "):
s = s[9:]
gametype = discordgo.GameTypeWatching
msg = "Set watching "
default:
msg = "Set game to "
}
usd := discordgo.UpdateStatusData{
Status: string(d.State.Settings.Status),
Game: &discordgo.Game{
Name: s,
Type: gametype,
},
}
if err := d.UpdateStatusComplex(usd); err != nil {
Message(err.Error())
return
}
if s != "" {
Message(msg + s + ".")
} else {
Message("Reset presence successfully.")
}
}