httpsms-gateway / api /pkg /discord /application_service.go
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca
Raw History Blame Contribute Delete
992 Bytes
package discord
import (
"context"
"encoding/json"
"fmt"
"net/http"
)
// ApplicationService is the API client for the interacting with commands
type ApplicationService service
// CreateCommand creates a new guild command
//
// API Docs: https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
func (service *ApplicationService) CreateCommand(ctx context.Context, serverID string, params *CommandCreateRequest) (*CommandCreateResponse, *Response, error) {
url := fmt.Sprintf("/applications/%s/guilds/%s/commands", service.client.applicationID, serverID)
request, err := service.client.newRequest(ctx, http.MethodPost, url, params)
if err != nil {
return nil, nil, err
}
response, err := service.client.do(request)
if err != nil {
return nil, response, err
}
message := new(CommandCreateResponse)
if err = json.Unmarshal(*response.Body, message); err != nil {
return nil, response, err
}
return message, response, nil
}