Bulk command overwrite (#926)
* add session.ApplicationCommandBulkOverwrite * change ApplicationCommandBulkOverwrite to take a guildID * formatting * add omitempty to ID of ApplicationCommand
This commit is contained in:
parent
cbae312c9d
commit
7d7206b01b
2 changed files with 20 additions and 1 deletions
|
@ -15,7 +15,7 @@ const InteractionDeadline = time.Second * 3
|
|||
|
||||
// ApplicationCommand represents an application's slash command.
|
||||
type ApplicationCommand struct {
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id,omitempty"`
|
||||
ApplicationID string `json:"application_id,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description,omitempty"`
|
||||
|
|
19
restapi.go
19
restapi.go
|
@ -2472,6 +2472,25 @@ func (s *Session) ApplicationCommandEdit(appID, guildID, cmdID string, cmd *Appl
|
|||
return
|
||||
}
|
||||
|
||||
// ApplicationCommandBulkOverwrite Creates commands overwriting existing commands. Returns a list of commands.
|
||||
// appID : The application ID.
|
||||
// commands : The commands to create.
|
||||
func (s *Session) ApplicationCommandBulkOverwrite(appID string, guildID string, commands []*ApplicationCommand) (createdCommands []*ApplicationCommand, err error) {
|
||||
endpoint := EndpointApplicationGlobalCommands(appID)
|
||||
if guildID != "" {
|
||||
endpoint = EndpointApplicationGuildCommands(appID, guildID)
|
||||
}
|
||||
|
||||
body, err := s.RequestWithBucketID("PUT", endpoint, commands, endpoint)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = unmarshal(body, &createdCommands)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ApplicationCommandDelete deletes application command by ID.
|
||||
// appID : The application ID.
|
||||
// cmdID : Application command ID to delete.
|
||||
|
|
Loading…
Reference in a new issue