aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--main.go9
3 files changed, 11 insertions, 1 deletions
diff --git a/go.mod b/go.mod
index 1321ae7..16d6af9 100644
--- a/go.mod
+++ b/go.mod
@@ -20,6 +20,7 @@ require (
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
+ github.com/joho/godotenv v1.5.1 // indirect
github.com/redis/go-redis/v9 v9.9.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/sync v0.14.0 // indirect
diff --git a/go.sum b/go.sum
index fb058ce..0b8314f 100644
--- a/go.sum
+++ b/go.sum
@@ -34,6 +34,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
+github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
+github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
diff --git a/main.go b/main.go
index 91b7d9d..4610bc4 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@ package main
import (
_ "embed"
+ "errors"
"flag"
"github.com/anhgelus/gokord"
"github.com/anhgelus/gokord/utils"
@@ -9,6 +10,8 @@ import (
"github.com/anhgelus/les-copaings-bot/config"
"github.com/anhgelus/les-copaings-bot/user"
"github.com/bwmarrin/discordgo"
+ "github.com/joho/godotenv"
+ "os"
"time"
)
@@ -26,7 +29,11 @@ var (
)
func init() {
- flag.StringVar(&token, "token", "", "token of the bot")
+ err := godotenv.Load()
+ if err != nil && !errors.Is(err, os.ErrNotExist) {
+ utils.SendWarn("Error while loading .env file", "error", err.Error())
+ }
+ flag.StringVar(&token, "token", os.Getenv("TOKEN"), "token of the bot")
}
func main() {