mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Subject: [PATCH] feat(ClientApplication): Approximate guild count and new
`GET` route (#9713) Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ const Permissions = require('../util/Permissions');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Client OAuth2 Application.
|
* Represents a client application.
|
||||||
* @extends {Application}
|
* @extends {Application}
|
||||||
*/
|
*/
|
||||||
class ClientApplication extends Application {
|
class ClientApplication extends Application {
|
||||||
@@ -69,6 +69,26 @@ class ClientApplication extends Application {
|
|||||||
this.flags = new ApplicationFlags(data.flags).freeze();
|
this.flags = new ApplicationFlags(data.flags).freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('approximate_guild_count' in data) {
|
||||||
|
/**
|
||||||
|
* An approximate amount of guilds this application is in.
|
||||||
|
* @type {?number}
|
||||||
|
*/
|
||||||
|
this.approximateGuildCount = data.approximate_guild_count;
|
||||||
|
} else {
|
||||||
|
this.approximateGuildCount ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('guild_id' in data) {
|
||||||
|
/**
|
||||||
|
* The id of the guild associated with this application.
|
||||||
|
* @type {?Snowflake}
|
||||||
|
*/
|
||||||
|
this.guildId = data.guild_id;
|
||||||
|
} else {
|
||||||
|
this.guildId ??= null;
|
||||||
|
}
|
||||||
|
|
||||||
if ('cover_image' in data) {
|
if ('cover_image' in data) {
|
||||||
/**
|
/**
|
||||||
* The hash of the application's cover image
|
* The hash of the application's cover image
|
||||||
@@ -120,6 +140,15 @@ class ClientApplication extends Application {
|
|||||||
: this.owner ?? null;
|
: this.owner ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The guild associated with this application.
|
||||||
|
* @type {?Guild}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get guild() {
|
||||||
|
return this.client.guilds.cache.get(this.guildId) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this application is partial
|
* Whether this application is partial
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -134,8 +163,8 @@ class ClientApplication extends Application {
|
|||||||
* @returns {Promise<ClientApplication>}
|
* @returns {Promise<ClientApplication>}
|
||||||
*/
|
*/
|
||||||
async fetch() {
|
async fetch() {
|
||||||
const app = await this.client.api.oauth2.applications('@me').get();
|
const data = await this.client.api.applications('@me').get();
|
||||||
this._patch(app);
|
this._patch(data);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
typings/index.d.ts
vendored
3
typings/index.d.ts
vendored
@@ -677,11 +677,14 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
|||||||
|
|
||||||
export class ClientApplication extends Application {
|
export class ClientApplication extends Application {
|
||||||
private constructor(client: Client, data: RawClientApplicationData);
|
private constructor(client: Client, data: RawClientApplicationData);
|
||||||
|
public approximateGuildCount: number | null;
|
||||||
public botPublic: boolean | null;
|
public botPublic: boolean | null;
|
||||||
public botRequireCodeGrant: boolean | null;
|
public botRequireCodeGrant: boolean | null;
|
||||||
public commands: ApplicationCommandManager;
|
public commands: ApplicationCommandManager;
|
||||||
public cover: string | null;
|
public cover: string | null;
|
||||||
public flags: Readonly<ApplicationFlags>;
|
public flags: Readonly<ApplicationFlags>;
|
||||||
|
public guildId: Snowflake | null;
|
||||||
|
public readonly guild: Guild | null;
|
||||||
public tags: string[];
|
public tags: string[];
|
||||||
public installParams: ClientApplicationInstallParams | null;
|
public installParams: ClientApplicationInstallParams | null;
|
||||||
public customInstallURL: string | null;
|
public customInstallURL: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user