use env variables
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
@@ -4,21 +4,19 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"hal/commands"
|
"hal/commands"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
tempest "github.com/Amatsagu/Tempest"
|
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() {
|
func main() {
|
||||||
|
fmt.Println("### ENV ###", os.Getenv("TOKEN"))
|
||||||
|
|
||||||
client := tempest.CreateClient(tempest.ClientOptions{
|
client := tempest.CreateClient(tempest.ClientOptions{
|
||||||
ApplicationId: AppID,
|
ApplicationId: tempest.StringToSnowflake(os.Getenv("APP_ID")),
|
||||||
PublicKey: PublicKey,
|
PublicKey: os.Getenv("PUBLIC_KEY"),
|
||||||
Token: Token,
|
Token: os.Getenv("TOKEN"),
|
||||||
PreCommandExecutionHandler: func(itx tempest.CommandInteraction) *tempest.ResponseData {
|
PreCommandExecutionHandler: func(itx tempest.CommandInteraction) *tempest.ResponseData {
|
||||||
log.Printf("running [%s] slash command", itx.Data.Name)
|
log.Printf("running [%s] slash command", itx.Data.Name)
|
||||||
return nil
|
return nil
|
||||||
@@ -34,7 +32,6 @@ func main() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
log.Printf("starting server at %s", Addr)
|
|
||||||
|
|
||||||
client.RegisterCommand(commands.Hello)
|
client.RegisterCommand(commands.Hello)
|
||||||
client.RegisterCommand(commands.Pinned)
|
client.RegisterCommand(commands.Pinned)
|
||||||
@@ -43,7 +40,11 @@ func main() {
|
|||||||
992760761812258868, // test server
|
992760761812258868, // test server
|
||||||
}, nil, false)
|
}, nil, false)
|
||||||
|
|
||||||
if err := client.ListenAndServe(Addr); err != nil {
|
|
||||||
|
addr := os.Getenv("RAILWAY_STATIC_URL")
|
||||||
|
if err := client.ListenAndServe(addr); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("starting server at %s", addr)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user