diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..49468ed --- /dev/null +++ b/.air.toml @@ -0,0 +1,46 @@ +root = "." +testdata_dir = "testdata" +tmp_dir = "tmp" + +[build] + args_bin = [] + bin = "./tmp/main" + cmd = "go build -o ./tmp/main ." + delay = 1000 + exclude_dir = ["assets", "tmp", "vendor", "testdata"] + exclude_file = [] + exclude_regex = ["_test.go"] + exclude_unchanged = false + follow_symlink = false + full_bin = "" + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html"] + include_file = [] + kill_delay = "0s" + log = "build-errors.log" + poll = false + poll_interval = 0 + post_cmd = [] + pre_cmd = [] + rerun = false + rerun_delay = 500 + send_interrupt = false + stop_on_error = false + +[color] + app = "" + build = "yellow" + main = "magenta" + runner = "green" + watcher = "cyan" + +[log] + main_only = false + time = false + +[misc] + clean_on_exit = false + +[screen] + clear_on_rebuild = false + keep_scroll = true diff --git a/.gitignore b/.gitignore index 3b735ec..3068eeb 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ # Go workspace file go.work + +# No env leaky plz +*.env diff --git a/go.mod b/go.mod index 5a960ff..0e15546 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,10 @@ module butler-go go 1.21.0 -require github.com/bwmarrin/discordgo v0.27.1 +require ( + github.com/bwmarrin/discordgo v0.27.1 + github.com/joho/godotenv v1.5.1 +) require ( github.com/gorilla/websocket v1.4.2 // indirect diff --git a/go.sum b/go.sum index 05dcc79..7d1da0c 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4Ho github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= diff --git a/main.go b/main.go index f53638f..bddce37 100644 --- a/main.go +++ b/main.go @@ -1,25 +1,29 @@ package main import ( - "flag" "fmt" + "log" "os" "os/signal" "syscall" "github.com/bwmarrin/discordgo" + "github.com/joho/godotenv" ) -func init() { - flag.StringVar(&token, "t", "", "Bot Token") - flag.Parse() -} - var token string -func main() { - fmt.Println("Initializing.......") +func init() { + // load env variables + err := godotenv.Load() + if err != nil { + log.Fatal("Error loading .env file.") + } + token = os.Getenv("TOKEN") +} + +func main() { // Create a new Discord session using the provided bot token. dg, err := discordgo.New("Bot " + token) if err != nil { @@ -27,6 +31,8 @@ func main() { return } + dg.UpdateGameStatus(1, "I'm programmed in Go!") + // Register the messageCreate func as a callback for MessageCreate events. dg.AddHandler(messageCreate) diff --git a/tmp/build-errors.log b/tmp/build-errors.log new file mode 100644 index 0000000..40b5ed1 --- /dev/null +++ b/tmp/build-errors.log @@ -0,0 +1 @@ +exit status 1exit status 1exit status 1exit status 1 \ No newline at end of file diff --git a/tmp/main b/tmp/main new file mode 100755 index 0000000..265acae Binary files /dev/null and b/tmp/main differ