Spaces:
Paused
Paused
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 Download api/pkg/discord/application_service.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 992 Bytes
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/application_service.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/discord/application_service.go
-
curl -L -o application_service.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/application_service.go
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 | |
| } | |