send mode impl, wip default guild/channel setting

This commit is contained in:
Cynthia Foxwell 2023-07-08 19:17:47 -06:00
parent 10ba1af405
commit 7a69523b09
6 changed files with 173 additions and 20 deletions

View file

@ -3,13 +3,39 @@ package events
import (
"fmt"
"github.com/Cynosphere/comcord/state"
"github.com/bwmarrin/discordgo"
"github.com/fatih/color"
"github.com/mgutz/ansi"
)
func Ready(session *discordgo.Session, event *discordgo.Ready) {
fmt.Print("Logged in as: ")
color.Set(color.FgYellow)
fmt.Printf("%s (%s)\n", session.State.User.Username, session.State.User.ID)
color.Unset()
fmt.Printf("\rLogged in as: %s%s (%s)%s\n\r", ansi.ColorCode("yellow"), session.State.User.Username, session.State.User.ID, ansi.ColorCode("reset"))
state.SetNameLength(len(session.State.User.Username) + 2)
defaultGuild := state.GetConfigValue("defaultGuild")
defaultChannel := state.GetConfigValue("defaultChannel")
if defaultGuild != "" {
//var guild discordgo.Guild
hasGuild := false
for _, g := range session.State.Guilds {
if g.ID == defaultGuild {
//guild = *g
hasGuild = true
break
}
}
if hasGuild {
if defaultChannel != "" {
state.SetCurrentChannel(defaultChannel)
state.SetLastChannel(defaultGuild, defaultChannel)
}
} else {
fmt.Println("\r% This account is not in the defined default guild.")
}
} else {
if defaultChannel != "" {
fmt.Println("\r% Default channel defined without defining default guild.")
}
}
}