Fix slash command creation

This commit is contained in:
rxdn 2021-08-30 21:59:11 +01:00
parent d90e6ac262
commit 9d23c3ef39

View File

@ -8,6 +8,7 @@ import (
"github.com/TicketsBot/worker/bot/command/impl/admin" "github.com/TicketsBot/worker/bot/command/impl/admin"
"github.com/TicketsBot/worker/bot/command/manager" "github.com/TicketsBot/worker/bot/command/manager"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rxdn/gdl/objects/interaction"
"github.com/rxdn/gdl/rest" "github.com/rxdn/gdl/rest"
"time" "time"
) )
@ -48,7 +49,7 @@ func GetWhitelabelCreateInteractions() func(*gin.Context) {
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, gin.H{
"success": false, "success": false,
"error": err.Error(), "error": err.Error(),
}) })
return return
} }
@ -59,14 +60,14 @@ func GetWhitelabelCreateInteractions() func(*gin.Context) {
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, gin.H{
"success": false, "success": false,
"error": err.Error(), "error": err.Error(),
}) })
return return
} }
ctx.JSON(400, gin.H{ ctx.JSON(400, gin.H{
"success": false, "success": false,
"error": fmt.Sprintf("Interaction creation on cooldown, please wait another %d seconds", int64(expiration.Seconds())), "error": fmt.Sprintf("Interaction creation on cooldown, please wait another %d seconds", int64(expiration.Seconds())),
}) })
return return
@ -76,7 +77,7 @@ func GetWhitelabelCreateInteractions() func(*gin.Context) {
if err != nil { if err != nil {
ctx.JSON(500, gin.H{ ctx.JSON(500, gin.H{
"success": false, "success": false,
"error": err.Error(), "error": err.Error(),
}) })
return return
} }
@ -95,6 +96,7 @@ func GetWhitelabelCreateInteractions() func(*gin.Context) {
Name: option.Name, Name: option.Name,
Description: option.Description, Description: option.Description,
Options: option.Options, Options: option.Options,
Type: interaction.ApplicationCommandTypeChatInput,
} }
interactions = append(interactions, data) interactions = append(interactions, data)
@ -107,7 +109,7 @@ func GetWhitelabelCreateInteractions() func(*gin.Context) {
} else { } else {
ctx.JSON(500, gin.H{ ctx.JSON(500, gin.H{
"success": false, "success": false,
"error": err.Error(), "error": err.Error(),
}) })
} }
} }