Skip to content

Commit 77b38d2

Browse files
JiraliteAmgelo563
andcommitted
fix: remove incorrect nullables, add ApplicationEmoji#available
Co-Authored-By: Amgelo563 <[email protected]>
1 parent 9d6fdf8 commit 77b38d2

File tree

3 files changed

+115
-20
lines changed

3 files changed

+115
-20
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
module.exports = ApplicationEmoji;

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,40 @@ class BaseGuildEmoji extends Emoji {
7272
* @deprecated Use {@link BaseGuildEmoji#imageURL} instead.
7373
*/
7474

75+
/**
76+
* The emoji's name
77+
* @name name
78+
* @memberof BaseGuildEmoji
79+
* @instance
80+
* @type {string}
81+
* @readonly
82+
*/
83+
84+
/**
85+
* Whether or not the emoji is animated
86+
* @name animated
87+
* @memberof BaseGuildEmoji
88+
* @instance
89+
* @type {boolean}
90+
* @readonly
91+
*/
92+
93+
/**
94+
* The time the emoji was created at.
95+
* @name createdAt
96+
* @memberof BaseGuildEmoji
97+
* @instance
98+
* @type {Date}
99+
* @readonly
100+
*/
101+
102+
/**
103+
* The timestamp the emoji was created at.
104+
* @name createdTimestamp
105+
* @memberof BaseGuildEmoji
106+
* @instance
107+
* @type {number}
108+
* @readonly
109+
*/
110+
75111
module.exports = BaseGuildEmoji;

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
} from '@discordjs/formatters';
3838
import { Awaitable, JSONEncodable } from '@discordjs/util';
3939
import { Collection, ReadonlyCollection } from '@discordjs/collection';
40-
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions, EmojiURLOptions } from '@discordjs/rest';
40+
import { BaseImageURLOptions, EmojiURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
4141
import {
4242
WebSocketManager as WSWebSocketManager,
4343
IShardingStrategy,
@@ -704,7 +704,9 @@ export class BaseGuildEmoji extends Emoji {
704704
public get createdTimestamp(): number;
705705
public guild: Guild | GuildPreview;
706706
public id: Snowflake;
707-
public managed: boolean | null;
707+
public name: string;
708+
public animated: boolean;
709+
public managed: boolean;
708710
public requiresColons: boolean | null;
709711
}
710712

@@ -1511,10 +1513,16 @@ export class ApplicationEmoji extends Emoji {
15111513
private constructor(client: Client<true>, data: RawApplicationEmojiData, application: ClientApplication);
15121514

15131515
public application: ClientApplication;
1514-
public author: User | null;
1516+
public author: User;
15151517
public id: Snowflake;
1516-
public managed: boolean | null;
1517-
public requiresColons: boolean | null;
1518+
public managed: false;
1519+
public requiresColons: true;
1520+
public name: string;
1521+
public animated: boolean;
1522+
public available: true;
1523+
public get createdAt(): Date;
1524+
public get createdTimestamp(): number;
1525+
public imageURL(options?: EmojiURLOptions): string;
15181526
public delete(): Promise<ApplicationEmoji>;
15191527
public edit(options: ApplicationEmojiEditOptions): Promise<ApplicationEmoji>;
15201528
public equals(other: ApplicationEmoji | unknown): boolean;

0 commit comments

Comments
 (0)