2019-05-10 08:21:59 +00:00
|
|
|
package settings
|
|
|
|
|
2019-05-10 08:53:58 +00:00
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
2019-05-10 08:21:59 +00:00
|
|
|
const (
|
|
|
|
version = "3.0.0"
|
|
|
|
discordTokenPath = "./tokens/.discordtoken"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Settings struct {
|
2019-05-10 08:53:58 +00:00
|
|
|
Version string
|
|
|
|
DiscordToken string
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-05-10 08:53:58 +00:00
|
|
|
func New() (*Settings, error) {
|
|
|
|
log.Print(os.Getwd())
|
|
|
|
discordToken, err := ioutil.ReadFile(discordTokenPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.Wrap(err, "cannot read discord token file")
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|
2019-05-10 08:53:58 +00:00
|
|
|
|
|
|
|
return &Settings{
|
|
|
|
Version: version,
|
|
|
|
DiscordToken: string(discordToken),
|
|
|
|
}, nil
|
2019-05-10 08:21:59 +00:00
|
|
|
}
|