Skip to content

Commit 86c1d26

Browse files
author
cane
authored
Update Applications (#290)
1 parent 012c4f5 commit 86c1d26

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

discord/application.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66
"time"
77

8+
"github.com/disgoorg/json"
89
"github.com/disgoorg/snowflake/v2"
910

1011
"github.com/disgoorg/disgo/internal/flags"
@@ -18,9 +19,11 @@ type Application struct {
1819
RPCOrigins []string `json:"rpc_origins"`
1920
BotPublic bool `json:"bot_public"`
2021
BotRequireCodeGrant bool `json:"bot_require_code_grant"`
22+
Bot *User `json:"bot,omitempty"`
2123
TermsOfServiceURL *string `json:"terms_of_service_url,omitempty"`
2224
PrivacyPolicyURL *string `json:"privacy_policy_url,omitempty"`
2325
CustomInstallURL *string `json:"custom_install_url,omitempty"`
26+
InteractionsEndpointURL *string `json:"interactions_endpoint_url,omitempty"`
2427
RoleConnectionsVerificationURL *string `json:"role_connections_verification_url"`
2528
InstallParams *InstallParams `json:"install_params"`
2629
Tags []string `json:"tags"`
@@ -29,10 +32,12 @@ type Application struct {
2932
VerifyKey string `json:"verify_key"`
3033
Team *Team `json:"team,omitempty"`
3134
GuildID *snowflake.ID `json:"guild_id,omitempty"`
35+
Guild *Guild `json:"guild,omitempty"`
3236
PrimarySkuID *snowflake.ID `json:"primary_sku_id,omitempty"`
3337
Slug *string `json:"slug,omitempty"`
3438
CoverImage *string `json:"cover_image,omitempty"`
3539
Flags ApplicationFlags `json:"flags,omitempty"`
40+
ApproximateGuildCount *int `json:"approximate_guild_count,omitempty"`
3641
}
3742

3843
func (a Application) IconURL(opts ...CDNOpt) *string {
@@ -55,6 +60,18 @@ func (a Application) CreatedAt() time.Time {
5560
return a.ID.Time()
5661
}
5762

63+
type ApplicationUpdate struct {
64+
CustomInstallURL *string `json:"custom_install_url,omitempty"`
65+
Description *string `json:"description,omitempty"`
66+
RoleConnectionsVerificationURL *string `json:"role_connections_verification_url,omitempty"`
67+
InstallParams *InstallParams `json:"install_params,omitempty"`
68+
Flags *ApplicationFlags `json:"flags,omitempty"`
69+
Icon *json.Nullable[Icon] `json:"icon,omitempty"`
70+
CoverImage *json.Nullable[Icon] `json:"cover_image,omitempty"`
71+
InteractionsEndpointURL *string `json:"interactions_endpoint_url,omitempty"`
72+
Tags []string `json:"tags,omitempty"`
73+
}
74+
5875
type PartialApplication struct {
5976
ID snowflake.ID `json:"id"`
6077
Flags ApplicationFlags `json:"flags"`

rest/applications.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ func NewApplications(client Client) Applications {
1313
}
1414

1515
type Applications interface {
16+
GetCurrentApplication(opts ...RequestOpt) (*discord.Application, error)
17+
UpdateCurrentApplication(applicationUpdate discord.ApplicationUpdate, opts ...RequestOpt) (*discord.Application, error)
18+
1619
GetGlobalCommands(applicationID snowflake.ID, withLocalizations bool, opts ...RequestOpt) ([]discord.ApplicationCommand, error)
1720
GetGlobalCommand(applicationID snowflake.ID, commandID snowflake.ID, opts ...RequestOpt) (discord.ApplicationCommand, error)
1821
CreateGlobalCommand(applicationID snowflake.ID, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (discord.ApplicationCommand, error)
@@ -38,6 +41,16 @@ type applicationsImpl struct {
3841
client Client
3942
}
4043

44+
func (s *applicationsImpl) GetCurrentApplication(opts ...RequestOpt) (application *discord.Application, err error) {
45+
err = s.client.Do(GetCurrentApplication.Compile(nil), nil, &application, opts...)
46+
return
47+
}
48+
49+
func (s *applicationsImpl) UpdateCurrentApplication(applicationUpdate discord.ApplicationUpdate, opts ...RequestOpt) (application *discord.Application, err error) {
50+
err = s.client.Do(UpdateCurrentApplication.Compile(nil), applicationUpdate, &application, opts...)
51+
return
52+
}
53+
4154
func (s *applicationsImpl) GetGlobalCommands(applicationID snowflake.ID, withLocalizations bool, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) {
4255
var unmarshalCommands []discord.UnmarshalApplicationCommand
4356
err = s.client.Do(GetGlobalCommands.Compile(discord.QueryValues{"with_localizations": withLocalizations}, applicationID), nil, &unmarshalCommands, opts...)

rest/rest_endpoints.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ var (
259259

260260
// Applications
261261
var (
262+
GetCurrentApplication = NewEndpoint(http.MethodGet, "/applications/@me")
263+
UpdateCurrentApplication = NewEndpoint(http.MethodPatch, "/applications/@me")
264+
262265
GetGlobalCommands = NewEndpoint(http.MethodGet, "/applications/{application.id}/commands")
263266
GetGlobalCommand = NewEndpoint(http.MethodGet, "/applications/{application.id}/command/{command.id}")
264267
CreateGlobalCommand = NewEndpoint(http.MethodPost, "/applications/{application.id}/commands")

0 commit comments

Comments
 (0)