Add database to config
This commit is contained in:
parent
b63a368c35
commit
7d8a2db77b
20
main.go
20
main.go
@ -13,10 +13,24 @@ import (
|
||||
var client *discordgo.Session
|
||||
|
||||
type Config struct {
|
||||
Token string `toml:"token"`
|
||||
GuildID string `toml:"guildId"`
|
||||
Discord Discord `toml:"discord"`
|
||||
Database Database `toml:"database"`
|
||||
}
|
||||
|
||||
type Discord struct {
|
||||
Token string `toml:"client"`
|
||||
GuildID string `toml:"guildid"`
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
Host string `toml:"host"`
|
||||
Port int `toml:"port"`
|
||||
Name string `toml:"name"`
|
||||
Username string `toml:"username"`
|
||||
Password string `toml:"password"`
|
||||
}
|
||||
|
||||
|
||||
func loadConfig(filename string) (Config, error) {
|
||||
var config Config
|
||||
_, err := toml.DecodeFile(filename, &config)
|
||||
@ -30,7 +44,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
client, err = discordgo.New("Bot " + config.Token)
|
||||
client, err = discordgo.New("Bot " + config.Discord.Token)
|
||||
if err != nil {
|
||||
fmt.Println("Error initializing bot:", err)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user