tmp
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
.env
|
env.go
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
env := getEnvVariables()
|
||||||
|
|
||||||
client := tempest.CreateClient(tempest.ClientOptions{
|
client := tempest.CreateClient(tempest.ClientOptions{
|
||||||
ApplicationId: tempest.StringToSnowflake(os.Getenv("APP_ID")),
|
ApplicationId: env.AppID,
|
||||||
PublicKey: os.Getenv("PUBLIC_KEY"),
|
PublicKey: env.PublicKey,
|
||||||
Token: os.Getenv("TOKEN"),
|
Token: env.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
|
||||||
@@ -39,10 +41,33 @@ func main() {
|
|||||||
}, nil, false)
|
}, nil, false)
|
||||||
|
|
||||||
|
|
||||||
addr := os.Getenv("RAILWAY_STATIC_URL")
|
addr := fmt.Sprintf("%s:%s", env.Addr, env.Port)
|
||||||
if err := client.ListenAndServe(fmt.Sprintf("%s:80", addr)); err != nil {
|
fmt.Println("starting server at", addr)
|
||||||
|
|
||||||
|
if err := client.ListenAndServe(addr); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("starting server at", addr)
|
}
|
||||||
|
|
||||||
|
func getEnvVariables() Env {
|
||||||
|
if os.Getenv("RAILWAY_ENVIRONMENT") == "production" {
|
||||||
|
return Env{
|
||||||
|
AppID: tempest.StringToSnowflake(os.Getenv("APP_ID")),
|
||||||
|
PublicKey: os.Getenv("PUBLIC_KEY"),
|
||||||
|
Token: os.Getenv("TOKEN"),
|
||||||
|
Port: "8080",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return LocalEnv
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Env struct {
|
||||||
|
AppID tempest.Snowflake
|
||||||
|
PublicKey string
|
||||||
|
Token string
|
||||||
|
Port string
|
||||||
|
Addr string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user