mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
refactor(application): remove fetchAssets (#7250)
This commit is contained in:
@@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||||
const { ClientApplicationAssetTypes, Endpoints } = require('../../util/Constants');
|
const { Endpoints } = require('../../util/Constants');
|
||||||
const Base = require('../Base');
|
const Base = require('../Base');
|
||||||
|
|
||||||
const AssetTypes = Object.keys(ClientApplicationAssetTypes);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an OAuth2 Application.
|
* Represents an OAuth2 Application.
|
||||||
* @abstract
|
* @abstract
|
||||||
@@ -92,27 +90,6 @@ class Application extends Base {
|
|||||||
return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size });
|
return Endpoints.CDN(this.client.options.http.cdn).AppIcon(this.id, this.cover, { format, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Asset data.
|
|
||||||
* @typedef {Object} ApplicationAsset
|
|
||||||
* @property {Snowflake} id The asset's id
|
|
||||||
* @property {string} name The asset's name
|
|
||||||
* @property {string} type The asset's type
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the application's rich presence assets.
|
|
||||||
* @returns {Promise<Array<ApplicationAsset>>}
|
|
||||||
*/
|
|
||||||
async fetchAssets() {
|
|
||||||
const assets = await this.client.api.oauth2.applications(this.id).assets.get();
|
|
||||||
return assets.map(a => ({
|
|
||||||
id: a.id,
|
|
||||||
name: a.name,
|
|
||||||
type: AssetTypes[a.type - 1],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When concatenated with a string, this automatically returns the application's name instead of the
|
* When concatenated with a string, this automatically returns the application's name instead of the
|
||||||
* Application object.
|
* Application object.
|
||||||
|
|||||||
@@ -573,11 +573,6 @@ exports.ThreadChannelTypes = ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD
|
|||||||
*/
|
*/
|
||||||
exports.VoiceBasedChannelTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];
|
exports.VoiceBasedChannelTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];
|
||||||
|
|
||||||
exports.ClientApplicationAssetTypes = {
|
|
||||||
SMALL: 1,
|
|
||||||
BIG: 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Colors = {
|
exports.Colors = {
|
||||||
DEFAULT: 0x000000,
|
DEFAULT: 0x000000,
|
||||||
WHITE: 0xffffff,
|
WHITE: 0xffffff,
|
||||||
|
|||||||
13
packages/discord.js/typings/index.d.ts
vendored
13
packages/discord.js/typings/index.d.ts
vendored
@@ -200,7 +200,6 @@ export abstract class Application extends Base {
|
|||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public name: string | null;
|
public name: string | null;
|
||||||
public coverURL(options?: StaticImageURLOptions): string | null;
|
public coverURL(options?: StaticImageURLOptions): string | null;
|
||||||
public fetchAssets(): Promise<ApplicationAsset[]>;
|
|
||||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
public iconURL(options?: StaticImageURLOptions): string | null;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
public toString(): string | null;
|
public toString(): string | null;
|
||||||
@@ -2776,7 +2775,6 @@ export const Constants: {
|
|||||||
ThreadChannelTypes: ThreadChannelTypes[];
|
ThreadChannelTypes: ThreadChannelTypes[];
|
||||||
TextBasedChannelTypes: TextBasedChannelTypes[];
|
TextBasedChannelTypes: TextBasedChannelTypes[];
|
||||||
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
|
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
|
||||||
ClientApplicationAssetTypes: ConstantsClientApplicationAssetTypes;
|
|
||||||
IntegrationExpireBehaviors: IntegrationExpireBehaviors[];
|
IntegrationExpireBehaviors: IntegrationExpireBehaviors[];
|
||||||
InviteScopes: InviteScope[];
|
InviteScopes: InviteScope[];
|
||||||
MessageTypes: MessageType[];
|
MessageTypes: MessageType[];
|
||||||
@@ -3502,12 +3500,6 @@ export interface APIRequest {
|
|||||||
route: string;
|
route: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApplicationAsset {
|
|
||||||
name: string;
|
|
||||||
id: Snowflake;
|
|
||||||
type: 'BIG' | 'SMALL';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseApplicationCommandData {
|
export interface BaseApplicationCommandData {
|
||||||
name: string;
|
name: string;
|
||||||
defaultPermission?: boolean;
|
defaultPermission?: boolean;
|
||||||
@@ -4067,11 +4059,6 @@ export interface CommandInteractionResolvedData<Cached extends CacheType = Cache
|
|||||||
messages?: Collection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
messages?: Collection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConstantsClientApplicationAssetTypes {
|
|
||||||
SMALL: 1;
|
|
||||||
BIG: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConstantsColors {
|
export interface ConstantsColors {
|
||||||
DEFAULT: 0x000000;
|
DEFAULT: 0x000000;
|
||||||
WHITE: 0xffffff;
|
WHITE: 0xffffff;
|
||||||
|
|||||||
@@ -809,7 +809,6 @@ expectType<'messageCreate'>(Constants.Events.MESSAGE_CREATE);
|
|||||||
expectType<'close'>(Constants.ShardEvents.CLOSE);
|
expectType<'close'>(Constants.ShardEvents.CLOSE);
|
||||||
expectType<1>(Constants.Status.CONNECTING);
|
expectType<1>(Constants.Status.CONNECTING);
|
||||||
expectType<0>(Constants.Opcodes.DISPATCH);
|
expectType<0>(Constants.Opcodes.DISPATCH);
|
||||||
expectType<2>(Constants.ClientApplicationAssetTypes.BIG);
|
|
||||||
|
|
||||||
declare const applicationCommandData: ApplicationCommandData;
|
declare const applicationCommandData: ApplicationCommandData;
|
||||||
declare const applicationCommandResolvable: ApplicationCommandResolvable;
|
declare const applicationCommandResolvable: ApplicationCommandResolvable;
|
||||||
|
|||||||
Reference in New Issue
Block a user