Properly setup bones for future work

This commit is contained in:
Sebastian Cabrera 2024-01-15 04:32:35 -05:00
parent 280c2e6b1c
commit d84c5e5b66
7 changed files with 70 additions and 9 deletions

46
.air.toml Normal file
View file

@ -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

3
.gitignore vendored
View file

@ -19,3 +19,6 @@
# Go workspace file # Go workspace file
go.work go.work
# No env leaky plz
*.env

5
go.mod
View file

@ -2,7 +2,10 @@ module butler-go
go 1.21.0 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 ( require (
github.com/gorilla/websocket v1.4.2 // indirect github.com/gorilla/websocket v1.4.2 // indirect

2
go.sum
View file

@ -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/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 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 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 h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= 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= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=

22
main.go
View file

@ -1,25 +1,29 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"log"
"os" "os"
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"github.com/joho/godotenv"
) )
func init() {
flag.StringVar(&token, "t", "", "Bot Token")
flag.Parse()
}
var token string var token string
func main() { func init() {
fmt.Println("Initializing.......") // 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. // Create a new Discord session using the provided bot token.
dg, err := discordgo.New("Bot " + token) dg, err := discordgo.New("Bot " + token)
if err != nil { if err != nil {
@ -27,6 +31,8 @@ func main() {
return return
} }
dg.UpdateGameStatus(1, "I'm programmed in Go!")
// Register the messageCreate func as a callback for MessageCreate events. // Register the messageCreate func as a callback for MessageCreate events.
dg.AddHandler(messageCreate) dg.AddHandler(messageCreate)

1
tmp/build-errors.log Normal file
View file

@ -0,0 +1 @@
exit status 1exit status 1exit status 1exit status 1

BIN
tmp/main Executable file

Binary file not shown.