use env variables
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.env
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user