From 7d8a2db77bd2b986053eaf56b9e9b77797d376e5 Mon Sep 17 00:00:00 2001 From: Joren Date: Sat, 6 Jul 2024 16:59:12 +0200 Subject: [PATCH] Add database to config --- main.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index fe0d3fd..102b92f 100644 --- a/main.go +++ b/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