Skip to content

Commit d0fd79c

Browse files
jaw0r3kJiralite
authored andcommitted
Subject: [PATCH] feat(ClientApplication): Approximate guild count and new
`GET` route (#9713) Co-authored-by: Jiralite <[email protected]>
1 parent 65bbed8 commit d0fd79c

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/structures/ClientApplication.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Permissions = require('../util/Permissions');
1515
*/
1616

1717
/**
18-
* Represents a Client OAuth2 Application.
18+
* Represents a client application.
1919
* @extends {Application}
2020
*/
2121
class ClientApplication extends Application {
@@ -69,6 +69,26 @@ class ClientApplication extends Application {
6969
this.flags = new ApplicationFlags(data.flags).freeze();
7070
}
7171

72+
if ('approximate_guild_count' in data) {
73+
/**
74+
* An approximate amount of guilds this application is in.
75+
* @type {?number}
76+
*/
77+
this.approximateGuildCount = data.approximate_guild_count;
78+
} else {
79+
this.approximateGuildCount ??= null;
80+
}
81+
82+
if ('guild_id' in data) {
83+
/**
84+
* The id of the guild associated with this application.
85+
* @type {?Snowflake}
86+
*/
87+
this.guildId = data.guild_id;
88+
} else {
89+
this.guildId ??= null;
90+
}
91+
7292
if ('cover_image' in data) {
7393
/**
7494
* The hash of the application's cover image
@@ -120,6 +140,15 @@ class ClientApplication extends Application {
120140
: this.owner ?? null;
121141
}
122142

143+
/**
144+
* The guild associated with this application.
145+
* @type {?Guild}
146+
* @readonly
147+
*/
148+
get guild() {
149+
return this.client.guilds.cache.get(this.guildId) ?? null;
150+
}
151+
123152
/**
124153
* Whether this application is partial
125154
* @type {boolean}
@@ -134,8 +163,8 @@ class ClientApplication extends Application {
134163
* @returns {Promise<ClientApplication>}
135164
*/
136165
async fetch() {
137-
const app = await this.client.api.oauth2.applications('@me').get();
138-
this._patch(app);
166+
const data = await this.client.api.applications('@me').get();
167+
this._patch(data);
139168
return this;
140169
}
141170

typings/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,14 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
677677

678678
export class ClientApplication extends Application {
679679
private constructor(client: Client, data: RawClientApplicationData);
680+
public approximateGuildCount: number | null;
680681
public botPublic: boolean | null;
681682
public botRequireCodeGrant: boolean | null;
682683
public commands: ApplicationCommandManager;
683684
public cover: string | null;
684685
public flags: Readonly<ApplicationFlags>;
686+
public guildId: Snowflake | null;
687+
public readonly guild: Guild | null;
685688
public tags: string[];
686689
public installParams: ClientApplicationInstallParams | null;
687690
public customInstallURL: string | null;

0 commit comments

Comments
 (0)