Skip to content

Commit ef2c1bf

Browse files
Amgelo563QjuhJiralitekodiakhq[bot]
authored
fix(Emoji): remove incorrect nullables, add ApplicationEmoji#available (discordjs#10913)
* types: remove unintended nullables from app and base guild emojis * feat: add ApplicationEmoji#available * types(BaseGuildEmoji): fix incorrect JSDoc type for BaseGuildEmoji#name Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * types(Emoji): switch from # to . for property deprecation links Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * fix: remove default nulls in app emoji constructor on non-nullables * types(Emoji): replace raw data type pre 78d512c * types(Emoji): switch to ImageURLOptions for imageURL() Re-applies changes from discordjs#10613 Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * types(Emoji): remove deprecated `url` props types and descriptions Added by mistake in PR that used to target v14 Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * refactor(Emoji): wording and formatting changes to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * refactor(Emoji): missed wording and formatting change to prop descriptions Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * fix(Emoji)!: remove non present Emoji#url from typings * fix(Emoji): re-apply emoji url types from 2c35084 --------- Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 762bbc6 commit ef2c1bf

File tree

3 files changed

+114
-21
lines changed

3 files changed

+114
-21
lines changed

packages/discord.js/src/structures/ApplicationEmoji.js

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,42 @@ class ApplicationEmoji extends Emoji {
1616
*/
1717
this.application = application;
1818

19-
/**
20-
* The user who created this emoji
21-
* @type {?User}
22-
*/
23-
this.author = null;
24-
25-
this.managed = null;
26-
this.requiresColons = null;
27-
2819
this._patch(data);
2920
}
3021

3122
_patch(data) {
3223
if ('name' in data) this.name = data.name;
33-
if (data.user) this.author = this.client.users._add(data.user);
24+
if (data.user) {
25+
/**
26+
* The user who created this emoji
27+
* @type {User}
28+
*/
29+
this.author = this.client.users._add(data.user);
30+
}
3431

3532
if ('managed' in data) {
3633
/**
37-
* Whether this emoji is managed by an external service
38-
* @type {?boolean}
34+
* Whether this emoji is managed by an external service. Always `false` for application emojis
35+
* @type {false}
3936
*/
4037
this.managed = data.managed;
4138
}
4239

4340
if ('require_colons' in data) {
4441
/**
45-
* Whether or not this emoji requires colons surrounding it
46-
* @type {?boolean}
42+
* Whether this emoji requires colons surrounding it. Always `true` for application emojis
43+
* @type {true}
4744
*/
4845
this.requiresColons = data.require_colons;
4946
}
47+
48+
if ('available' in data) {
49+
/**
50+
* Whether this emoji is available. Always `true` for application emojis
51+
* @type {true}
52+
*/
53+
this.available = data.available;
54+
}
5055
}
5156

5257
/**
@@ -107,12 +112,58 @@ class ApplicationEmoji extends Emoji {
107112
other.id === this.id &&
108113
other.name === this.name &&
109114
other.managed === this.managed &&
110-
other.requiresColons === this.requiresColons
115+
other.requiresColons === this.requiresColons &&
116+
other.available === this.available
111117
);
112118
}
113119

114120
return other.id === this.id && other.name === this.name;
115121
}
116122
}
117123

124+
/**
125+
* The emoji's name
126+
* @name name
127+
* @memberof ApplicationEmoji
128+
* @instance
129+
* @type {string}
130+
* @readonly
131+
*/
132+
133+
/**
134+
* Whether the emoji is animated
135+
* @name animated
136+
* @memberof ApplicationEmoji
137+
* @instance
138+
* @type {boolean}
139+
* @readonly
140+
*/
141+
142+
/**
143+
* Returns a URL for the emoji.
144+
* @method imageURL
145+
* @memberof ApplicationEmoji
146+
* @instance
147+
* @param {EmojiURLOptions} [options] Options for the image URL
148+
* @returns {string}
149+
*/
150+
151+
/**
152+
* The time the emoji was created at
153+
* @name createdAt
154+
* @memberof ApplicationEmoji
155+
* @instance
156+
* @type {Date}
157+
* @readonly
158+
*/
159+
160+
/**
161+
* The timestamp the emoji was created at
162+
* @name createdTimestamp
163+
* @memberof ApplicationEmoji
164+
* @instance
165+
* @type {number}
166+
* @readonly
167+
*/
168+
118169
exports.ApplicationEmoji = ApplicationEmoji;

packages/discord.js/src/structures/BaseGuildEmoji.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,40 @@ class BaseGuildEmoji extends Emoji {
6262
* @returns {string}
6363
*/
6464

65+
/**
66+
* The emoji's name
67+
* @name name
68+
* @memberof BaseGuildEmoji
69+
* @instance
70+
* @type {string}
71+
* @readonly
72+
*/
73+
74+
/**
75+
* Whether or not the emoji is animated
76+
* @name animated
77+
* @memberof BaseGuildEmoji
78+
* @instance
79+
* @type {boolean}
80+
* @readonly
81+
*/
82+
83+
/**
84+
* The time the emoji was created at.
85+
* @name createdAt
86+
* @memberof BaseGuildEmoji
87+
* @instance
88+
* @type {Date}
89+
* @readonly
90+
*/
91+
92+
/**
93+
* The timestamp the emoji was created at.
94+
* @name createdTimestamp
95+
* @memberof BaseGuildEmoji
96+
* @instance
97+
* @type {number}
98+
* @readonly
99+
*/
100+
65101
exports.BaseGuildEmoji = BaseGuildEmoji;

packages/discord.js/typings/index.d.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,13 +591,14 @@ export abstract class BaseGuild extends Base {
591591
export class BaseGuildEmoji extends Emoji {
592592
protected constructor(client: Client<true>, data: APIEmoji, guild: Guild | GuildPreview);
593593
public imageURL(options?: EmojiURLOptions): string;
594-
public get url(): string;
595594
public available: boolean | null;
596595
public get createdAt(): Date;
597596
public get createdTimestamp(): number;
598597
public guild: Guild | GuildPreview;
599598
public id: Snowflake;
600-
public managed: boolean | null;
599+
public name: string;
600+
public animated: boolean;
601+
public managed: boolean;
601602
public requiresColons: boolean | null;
602603
}
603604

@@ -1268,7 +1269,6 @@ export class Emoji extends Base {
12681269
public name: string | null;
12691270
public get identifier(): string;
12701271
public imageURL(options?: EmojiURLOptions): string | null;
1271-
public get url(): string | null;
12721272
public toJSON(): unknown;
12731273
public toString(): string;
12741274
}
@@ -1286,10 +1286,16 @@ export class ApplicationEmoji extends Emoji {
12861286
private constructor(client: Client<true>, data: APIEmoji, application: ClientApplication);
12871287

12881288
public application: ClientApplication;
1289-
public author: User | null;
1289+
public author: User;
12901290
public id: Snowflake;
1291-
public managed: boolean | null;
1292-
public requiresColons: boolean | null;
1291+
public managed: false;
1292+
public requiresColons: true;
1293+
public name: string;
1294+
public animated: boolean;
1295+
public available: true;
1296+
public get createdAt(): Date;
1297+
public get createdTimestamp(): number;
1298+
public imageURL(options?: EmojiURLOptions): string;
12931299
public delete(): Promise<ApplicationEmoji>;
12941300
public edit(options: ApplicationEmojiEditOptions): Promise<ApplicationEmoji>;
12951301
public equals(other: ApplicationEmoji | unknown): boolean;

0 commit comments

Comments
 (0)