fix: 🐛 JSDoc

This commit is contained in:
Elysia 2023-04-22 13:32:37 +07:00
parent 26f48c90e4
commit e5ee2831f0
3 changed files with 28 additions and 4 deletions

View File

@ -296,10 +296,24 @@ class User extends Base {
if ('badges' in data) {
/**
* User badges (Boost, Slash, AutoMod, etc.)
* @type {?Array<{ id: string, description: string, icon: string, link?: string }>}
* @callback BadgeIcon
* @returns {string}
*/
this.badges = data.badges;
/**
* @typedef {Object} UserBadge
* @property {string} id The id of the badge
* @property {string} description The description of the badge
* @property {string} icon The icon hash of the badge
* @property {?string} link The link of the badge
* @property {BadgeIcon} iconURL The iconURL of the badge
*/
/**
* User badges (Boost, Slash, AutoMod, etc.)
* @type {?Array<UserBadge>}
*/
this.badges = data.badges.map(o => ({ ...o, iconURL: () => this.client.rest.cdn.BadgeIcon(o.icon) }));
}
if ('guild_badges' in data) {

View File

@ -227,6 +227,8 @@ exports.Endpoints = {
makeImageUrl(`${root}/role-icons/${roleId}/${hash}`, { size, format }),
guildScheduledEventCover: (scheduledEventId, coverHash, format, size) =>
makeImageUrl(`${root}/guild-events/${scheduledEventId}/${coverHash}`, { size, format }),
// Test only
BadgeIcon: hash => makeImageUrl(`${root}/badge-icons/${hash}.png`),
};
},
invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`),

10
typings/index.d.ts vendored
View File

@ -1605,6 +1605,14 @@ export class GuildEmoji extends BaseGuildEmoji {
public setName(name: string, reason?: string): Promise<GuildEmoji>;
}
export interface UserBadge {
name: string;
description: string;
icon: string;
link?: string;
iconURL(): string;
}
export class GuildMember extends PartialTextBasedChannel(Base) {
private constructor(client: Client, data: RawGuildMemberData, guild: Guild);
private _roles: Snowflake[];
@ -1637,7 +1645,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
public readonly voice: VoiceState;
public themeColors?: [number, number];
public readonly hexThemeColor: [string, string] | null;
public badges: { id: string; description: string; icon: string; link?: string }[] | null;
public badges: UserBadge[] | null;
public avatarURL(options?: ImageURLOptions): string | null;
public ban(options?: BanOptions): Promise<GuildMember>;
public disableCommunicationUntil(timeout: DateResolvable | null, reason?: string): Promise<GuildMember>;