Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit 9838b20

Browse files
author
jonas747
committed
add interaction and slash commands api
1 parent 7cb79dc commit 9838b20

File tree

6 files changed

+618
-12
lines changed

6 files changed

+618
-12
lines changed

endpoints.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,42 @@ var (
148148
EndpointOauth2 = EndpointAPI + "oauth2/"
149149
EndpointApplications = EndpointOauth2 + "applications"
150150
EndpointApplication = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) }
151+
EndpointApplicationMe = EndpointApplications + "/@me"
151152
EndpointApplicationsBot = func(aID int64) string { return EndpointApplications + "/" + StrID(aID) + "/bot" }
153+
154+
EndpointApplicationNonOauth2 = func(aID int64) string { return EndpointAPI + "applications/" + StrID(aID) }
155+
EndpointApplicationCommands = func(aID int64) string { return EndpointApplicationNonOauth2(aID) + "/commands" }
156+
EndpointApplicationCommand = func(aID int64, cmdID int64) string {
157+
return EndpointApplicationNonOauth2(aID) + "/commands/" + StrID(cmdID)
158+
}
159+
160+
EndpointApplicationGuildCommands = func(aID int64, gID int64) string {
161+
return EndpointApplicationNonOauth2(aID) + "/guilds/" + StrID(gID) + "/commands"
162+
}
163+
164+
EndpointApplicationGuildCommand = func(aID int64, gID int64, cmdID int64) string {
165+
return EndpointApplicationGuildCommands(aID, gID) + "/" + StrID(cmdID)
166+
}
167+
168+
EndpointApplicationGuildCommandsPermissions = func(aID int64, gID int64) string {
169+
return EndpointApplicationGuildCommands(aID, gID) + "/permissions"
170+
}
171+
172+
EndpointApplicationGuildCommandPermissions = func(aID int64, gID int64, cmdID int64) string {
173+
return EndpointApplicationGuildCommand(aID, gID, cmdID) + "/permissions"
174+
}
175+
176+
EndpointInteractions = EndpointAPI + "interactions"
177+
EndpointInteractionCallback = func(interactionID int64, token string) string {
178+
return EndpointInteractions + "/" + StrID(interactionID) + "/" + token + "/callback"
179+
}
180+
EndpointWebhookInteraction = func(applicationID int64, token string) string {
181+
return EndpointWebhooks + "/" + StrID(applicationID) + "/" + token
182+
}
183+
EndpointInteractionOriginalMessage = func(applicationID int64, token string) string {
184+
return EndpointWebhookInteraction(applicationID, token) + "/messages/@original"
185+
}
186+
EndpointInteractionFollowupMessage = func(applicationID int64, token string, messageID int64) string {
187+
return EndpointWebhookInteraction(applicationID, token) + "/messages/" + StrID(messageID)
188+
}
152189
)

eventhandlers.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

events.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,7 @@ type InviteDelete struct {
425425
ChannelID int64 `json:"channel_id,string"`
426426
Code string `json:"code"`
427427
}
428+
429+
type InteractionCreate struct {
430+
*Interaction
431+
}

oauth2.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package discordgo
1515

1616
// An Application struct stores values for a Discord OAuth2 Application
1717
type Application struct {
18-
ID int64 `json:"id,omitempty"`
18+
ID int64 `json:"id,string,omitempty"`
1919
Name string `json:"name"`
2020
Description string `json:"description,omitempty"`
2121
Icon string `json:"icon,omitempty"`
@@ -42,6 +42,18 @@ func (s *Session) Application(appID int64) (st *Application, err error) {
4242
return
4343
}
4444

45+
// Application returns an Application structure of the current bot
46+
func (s *Session) ApplicationMe() (st *Application, err error) {
47+
48+
body, err := s.RequestWithBucketID("GET", EndpointApplicationMe, nil, EndpointApplicationMe)
49+
if err != nil {
50+
return
51+
}
52+
53+
err = unmarshal(body, &st)
54+
return
55+
}
56+
4557
// Applications returns all applications for the authenticated user
4658
func (s *Session) Applications() (st []*Application, err error) {
4759

0 commit comments

Comments
 (0)