package state import ( "time" "github.com/bwmarrin/discordgo" ) type ComcordState struct { Config map[string]string Connected bool RPCConnected bool StartTime time.Time CurrentGuild string CurrentChannel string NameLength int InPrompt bool PromptText string AFK bool MessageQueue []*discordgo.Message LastChannel map[string]string LastDM string NoColor bool } var state ComcordState func Setup(config map[string]string) { state = ComcordState{} state.Config = config state.Connected = true state.RPCConnected = false state.StartTime = time.Now() state.CurrentGuild = "" state.CurrentChannel = "" state.NameLength = 2 state.InPrompt = false state.PromptText = "" state.AFK = false state.MessageQueue = make([]*discordgo.Message, 0) state.LastChannel = make(map[string]string) state.LastDM = "" state.NoColor = false } func IsConnected() bool { return state.Connected } func SetConnected(value bool) { state.Connected = value } func IsRPCConnected() bool { return state.RPCConnected } func SetRPCConnected(value bool) { state.RPCConnected = value } func GetStartTime() time.Time { return state.StartTime } func GetCurrentGuild() string { return state.CurrentGuild } func SetCurrentGuild(value string) { state.CurrentGuild = value } func GetCurrentChannel() string { return state.CurrentChannel } func SetCurrentChannel(value string) { state.CurrentChannel = value } func GetNameLength() int { return state.NameLength } func SetNameLength(value int) { state.NameLength = value } func IsInPrompt() bool { return state.InPrompt } func SetInPrompt(value bool) { state.InPrompt = value } func GetPromptText() string { return state.PromptText } func SetPromptText(value string) { state.PromptText = value } func IsAFK() bool { return state.AFK } func SetAFK(value bool) { state.AFK = value } func GetMessageQueue() []*discordgo.Message { return state.MessageQueue } func AddMessageToQueue(msg *discordgo.Message) { state.MessageQueue = append(state.MessageQueue, msg) } func EmptyMessageQueue() { state.MessageQueue = make([]*discordgo.Message, 0) } func SetLastChannel(guild string, channel string) { state.LastChannel[guild] = channel } func GetLastChannel(guild string) string { channel, has := state.LastChannel[guild] if has { return channel } else { return "" } } func GetLastDM() string { return state.LastDM } func SetLastDM(value string) { state.LastDM = value } func GetConfigValue(key string) string { value, has := state.Config[key] if has { return value } else { return "" } } func SetNoColor(value bool) { state.NoColor = value } func HasNoColor() bool { return state.NoColor }