Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(application): remove fetchAssets #7250

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 1 addition & 24 deletions packages/discord.js/src/structures/interfaces/Application.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use strict';

const { DiscordSnowflake } = require('@sapphire/snowflake');
const { ClientApplicationAssetTypes, Endpoints } = require('../../util/Constants');
const { Endpoints } = require('../../util/Constants');
const Base = require('../Base');

const AssetTypes = Object.keys(ClientApplicationAssetTypes);

/**
* Represents an OAuth2 Application.
* @abstract
Expand Down Expand Up @@ -92,27 +90,6 @@ class Application extends Base {
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
* Application object.
Expand Down
5 changes: 0 additions & 5 deletions packages/discord.js/src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,6 @@ exports.ThreadChannelTypes = ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD
*/
exports.VoiceBasedChannelTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];

exports.ClientApplicationAssetTypes = {
SMALL: 1,
BIG: 2,
};

exports.Colors = {
DEFAULT: 0x000000,
WHITE: 0xffffff,
Expand Down
13 changes: 0 additions & 13 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export abstract class Application extends Base {
public id: Snowflake;
public name: string | null;
public coverURL(options?: StaticImageURLOptions): string | null;
public fetchAssets(): Promise<ApplicationAsset[]>;
public iconURL(options?: StaticImageURLOptions): string | null;
public toJSON(): unknown;
public toString(): string | null;
Expand Down Expand Up @@ -2776,7 +2775,6 @@ export const Constants: {
ThreadChannelTypes: ThreadChannelTypes[];
TextBasedChannelTypes: TextBasedChannelTypes[];
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
ClientApplicationAssetTypes: ConstantsClientApplicationAssetTypes;
IntegrationExpireBehaviors: IntegrationExpireBehaviors[];
InviteScopes: InviteScope[];
MessageTypes: MessageType[];
Expand Down Expand Up @@ -3502,12 +3500,6 @@ export interface APIRequest {
route: string;
}

export interface ApplicationAsset {
name: string;
id: Snowflake;
type: 'BIG' | 'SMALL';
}

export interface BaseApplicationCommandData {
name: string;
defaultPermission?: boolean;
Expand Down Expand Up @@ -4067,11 +4059,6 @@ export interface CommandInteractionResolvedData<Cached extends CacheType = Cache
messages?: Collection<Snowflake, CacheTypeReducer<Cached, Message, APIMessage>>;
}

export interface ConstantsClientApplicationAssetTypes {
SMALL: 1;
BIG: 2;
}

export interface ConstantsColors {
DEFAULT: 0x000000;
WHITE: 0xffffff;
Expand Down
1 change: 0 additions & 1 deletion packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ expectType<'messageCreate'>(Constants.Events.MESSAGE_CREATE);
expectType<'close'>(Constants.ShardEvents.CLOSE);
expectType<1>(Constants.Status.CONNECTING);
expectType<0>(Constants.Opcodes.DISPATCH);
expectType<2>(Constants.ClientApplicationAssetTypes.BIG);

declare const applicationCommandData: ApplicationCommandData;
declare const applicationCommandResolvable: ApplicationCommandResolvable;
Expand Down