show custom status with status-get
@@ -126,21 +126,38 @@ func NewStatusSetCustomCommand(session *discordgo.Session) *StatusSetCustomCmd {
return &StatusSetCustomCmd{session}
}
+func statusColor(status discordgo.Status) string {
+ switch status {
+ case discordgo.StatusOnline:
+ return "green"
+ case discordgo.StatusDoNotDisturb:
+ return tviewutil.ColorToHex(config.GetTheme().ErrorColor)
+ case discordgo.StatusIdle:
+ return "yellow"
+ case discordgo.StatusInvisible, discordgo.StatusOffline:
+ return "gray"
+ default:
+ return "gray"
+ }
+}
+
func statusToString(status discordgo.Status) string {
+ statusString := "[" + statusColor(status) + "]"
switch status {
case discordgo.StatusOnline:
- return "[green]Online[white]"
+ statusString += "Online"
case discordgo.StatusDoNotDisturb:
- return "[" + tviewutil.ColorToHex(config.GetTheme().ErrorColor) + "]Do not disturb[white]"
+ statusString += "Do not disturb"
case discordgo.StatusIdle:
- return "[yellow]Idle[white]"
+ statusString += "Idle"
case discordgo.StatusInvisible:
- return "[gray]Invisible[white]"
+ statusString += "Invisible"
case discordgo.StatusOffline:
- return "[gray]Offline[white]"
+ statusString += "Offline"
default:
- return "Unknown status"
+ statusString += "Unknown status"
}
+ return statusString
}
func (cmd *StatusGetCmd) Execute(writer io.Writer, parameters []string) {
@@ -151,7 +168,13 @@ func (cmd *StatusGetCmd) Execute(writer io.Writer, parameters []string) {
}
if len(parameters) == 0 {
- fmt.Fprintln(writer, statusToString(cmd.session.State.Settings.Status))
+ fmt.Fprintf(writer, statusToString(cmd.session.State.Settings.Status))
+
+ customStatus := cmd.session.State.Settings.CustomStatus
+ if len(customStatus.Text) > 0 || len(customStatus.EmojiName) > 0 {
+ fmt.Fprintf(writer, ": %s %s", customStatus.EmojiName, customStatus.Text)
+ }
+ fmt.Fprintf(writer, "[white]\n")
return
}
