package state import ( "time" "github.com/diamondburned/arikawa/v3/discord" "github.com/diamondburned/ningen/v3" ) type ComcordState struct { Client *ningen.State Config map[string]string Readied bool Connected bool RPCConnected bool StartTime time.Time CurrentGuild string CurrentChannel string NameLength int InPrompt bool PromptText string AFK bool MessageQueue []discord.Message LastChannel map[string]string LastDM string NoColor bool } var state ComcordState func Setup(config map[string]string, client *ningen.State) { state = ComcordState{} state.Client = client state.Config = config state.Readied = false 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([]discord.Message, 0) state.LastChannel = make(map[string]string) state.LastDM = "" state.NoColor = false } func GetClient() *ningen.State { return state.Client } func HasReadied() bool { return state.Readied } func SetReadied(value bool) { state.Readied = value } 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() []discord.Message { return state.MessageQueue } func AddMessageToQueue(msg discord.Message) { state.MessageQueue = append(state.MessageQueue, msg) } func EmptyMessageQueue() { state.MessageQueue = make([]discord.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 }