Start bot
This commit is contained in:
parent
fba7d2c8d4
commit
6cf715e620
11
go.mod
11
go.mod
@ -1,3 +1,14 @@
|
|||||||
module HwidBot
|
module HwidBot
|
||||||
|
|
||||||
go 1.22.4
|
go 1.22.4
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/BurntSushi/toml v1.4.0
|
||||||
|
github.com/bwmarrin/discordgo v0.28.1
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gorilla/websocket v1.4.2 // indirect
|
||||||
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
|
||||||
|
)
|
||||||
|
29
main.go
29
main.go
@ -2,8 +2,33 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main(){
|
type Config struct {
|
||||||
fmt.Println("Initial")
|
Token string `toml:"token"`
|
||||||
|
GuildID string `toml:"guildId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadConfig(filename string) (Config, error) {
|
||||||
|
var config Config
|
||||||
|
_, err := toml.DecodeFile(filename, &config)
|
||||||
|
return config, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func main(){
|
||||||
|
config, err := loadConfig("config.toml")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error occured whilst trying to load config: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := discordgo.New("Bot " + config.Token)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error initalizing bot: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer client.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user