use env variables

This commit is contained in:
mimu
2022-10-09 08:20:26 +02:00
parent 7061028af3
commit 6dd9cc219a
2 changed files with 12 additions and 10 deletions
+1
View File
@@ -0,0 +1 @@
.env
+11 -10
View File
@@ -4,21 +4,19 @@ import (
"fmt"
"hal/commands"
"log"
"os"
"time"
tempest "github.com/Amatsagu/Tempest"
)
const AppID tempest.Snowflake = 123
const PublicKey string = "public_key"
const Token string = "token"
const Addr string = "0.0.0.0:8080"
func main() {
fmt.Println("### ENV ###", os.Getenv("TOKEN"))
client := tempest.CreateClient(tempest.ClientOptions{
ApplicationId: AppID,
PublicKey: PublicKey,
Token: Token,
ApplicationId: tempest.StringToSnowflake(os.Getenv("APP_ID")),
PublicKey: os.Getenv("PUBLIC_KEY"),
Token: os.Getenv("TOKEN"),
PreCommandExecutionHandler: func(itx tempest.CommandInteraction) *tempest.ResponseData {
log.Printf("running [%s] slash command", itx.Data.Name)
return nil
@@ -34,7 +32,6 @@ func main() {
},
})
log.Printf("starting server at %s", Addr)
client.RegisterCommand(commands.Hello)
client.RegisterCommand(commands.Pinned)
@@ -43,7 +40,11 @@ func main() {
992760761812258868, // test server
}, nil, false)
if err := client.ListenAndServe(Addr); err != nil {
addr := os.Getenv("RAILWAY_STATIC_URL")
if err := client.ListenAndServe(addr); err != nil {
panic(err)
}
log.Printf("starting server at %s", addr)
}