mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(Partials): correctly document properties for partialized st… (#3922)
* fix(Partials): properly document partial properties * style: turn tabs into spaces * style: order properties alphabetically * fix(typings): PartialDMChannel will always have a recipient * change properties to undefined instead of null * docs: correctly mark properties * style: remove tabs * fix(partials): document properties properly * style: tabs * style: random line * docs(User): tag is nullable * typings(User/GuildMember): document lastMessageID properly * typings/fix: change lastMessageID to lastMessageChannelID Co-authored-by: Crawl <icrawltogo@gmail.com>
This commit is contained in:
@@ -38,14 +38,14 @@ class User extends Base {
|
|||||||
_patch(data) {
|
_patch(data) {
|
||||||
/**
|
/**
|
||||||
* The username of the user
|
* The username of the user
|
||||||
* @type {string}
|
* @type {?string}
|
||||||
* @name User#username
|
* @name User#username
|
||||||
*/
|
*/
|
||||||
if (data.username) this.username = data.username;
|
if (data.username) this.username = data.username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A discriminator based on username for the user
|
* A discriminator based on username for the user
|
||||||
* @type {string}
|
* @type {?string}
|
||||||
* @name User#discriminator
|
* @name User#discriminator
|
||||||
*/
|
*/
|
||||||
if (data.discriminator) this.discriminator = data.discriminator;
|
if (data.discriminator) this.discriminator = data.discriminator;
|
||||||
@@ -166,11 +166,11 @@ class User extends Base {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The Discord "tag" (e.g. `hydrabolt#0001`) for this user
|
* The Discord "tag" (e.g. `hydrabolt#0001`) for this user
|
||||||
* @type {string}
|
* @type {?string}
|
||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get tag() {
|
get tag() {
|
||||||
return `${this.username}#${this.discriminator}`;
|
return typeof this.username === 'string' ? `${this.username}#${this.discriminator}` : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
77
typings/index.d.ts
vendored
77
typings/index.d.ts
vendored
@@ -779,6 +779,7 @@ declare module 'discord.js' {
|
|||||||
public readonly joinedAt: Date | null;
|
public readonly joinedAt: Date | null;
|
||||||
public joinedTimestamp: number | null;
|
public joinedTimestamp: number | null;
|
||||||
public readonly kickable: boolean;
|
public readonly kickable: boolean;
|
||||||
|
public lastMessageChannelID: Snowflake | null;
|
||||||
public readonly manageable: boolean;
|
public readonly manageable: boolean;
|
||||||
public nickname: string | null;
|
public nickname: string | null;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
@@ -786,7 +787,7 @@ declare module 'discord.js' {
|
|||||||
public readonly premiumSince: Date | null;
|
public readonly premiumSince: Date | null;
|
||||||
public premiumSinceTimestamp: number | null;
|
public premiumSinceTimestamp: number | null;
|
||||||
public readonly presence: Presence;
|
public readonly presence: Presence;
|
||||||
public roles: GuildMemberRoleManager;
|
public readonly roles: GuildMemberRoleManager;
|
||||||
public user: User;
|
public user: User;
|
||||||
public readonly voice: VoiceState;
|
public readonly voice: VoiceState;
|
||||||
public ban(options?: BanOptions): Promise<GuildMember>;
|
public ban(options?: BanOptions): Promise<GuildMember>;
|
||||||
@@ -875,7 +876,7 @@ declare module 'discord.js' {
|
|||||||
public application: ClientApplication | null;
|
public application: ClientApplication | null;
|
||||||
public attachments: Collection<Snowflake, MessageAttachment>;
|
public attachments: Collection<Snowflake, MessageAttachment>;
|
||||||
public author: User;
|
public author: User;
|
||||||
public channel: TextChannel | DMChannel;
|
public channel: TextChannel | DMChannel | NewsChannel;
|
||||||
public readonly cleanContent: string;
|
public readonly cleanContent: string;
|
||||||
public content: string;
|
public content: string;
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date;
|
||||||
@@ -1434,6 +1435,7 @@ declare module 'discord.js' {
|
|||||||
public readonly defaultAvatarURL: string;
|
public readonly defaultAvatarURL: string;
|
||||||
public readonly dmChannel: DMChannel;
|
public readonly dmChannel: DMChannel;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
|
public lastMessageID: Snowflake | null;
|
||||||
public locale: string;
|
public locale: string;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
public readonly presence: Presence;
|
public readonly presence: Presence;
|
||||||
@@ -1935,10 +1937,7 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
interface PartialTextBasedChannelFields {
|
interface PartialTextBasedChannelFields {
|
||||||
lastMessageID: Snowflake | null;
|
lastMessageID: Snowflake | null;
|
||||||
lastMessageChannelID: Snowflake | null;
|
|
||||||
readonly lastMessage: Message | null;
|
readonly lastMessage: Message | null;
|
||||||
lastPinTimestamp: number | null;
|
|
||||||
readonly lastPinAt: Date;
|
|
||||||
send(
|
send(
|
||||||
options: MessageOptions | (MessageOptions & { split?: false }) | MessageAdditions | APIMessage,
|
options: MessageOptions | (MessageOptions & { split?: false }) | MessageAdditions | APIMessage,
|
||||||
): Promise<Message>;
|
): Promise<Message>;
|
||||||
@@ -1953,6 +1952,8 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
interface TextBasedChannelFields extends PartialTextBasedChannelFields {
|
||||||
|
lastPinTimestamp: number | null;
|
||||||
|
readonly lastPinAt: Date;
|
||||||
typing: boolean;
|
typing: boolean;
|
||||||
typingCount: number;
|
typingCount: number;
|
||||||
awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>;
|
||||||
@@ -2136,10 +2137,10 @@ declare module 'discord.js' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ClientEvents {
|
interface ClientEvents {
|
||||||
channelCreate: [ChannelTypes, PartialChannel];
|
channelCreate: [ChannelTypes];
|
||||||
channelDelete: [ChannelTypes, PartialChannel];
|
channelDelete: [ChannelTypes | PartialDMChannel];
|
||||||
channelPinsUpdate: [TextBasedChannelTypes | PartialChannel, Date];
|
channelPinsUpdate: [TextBasedChannelTypes | PartialDMChannel, Date];
|
||||||
channelUpdate: [ChannelTypes | PartialChannel, ChannelTypes | PartialChannel];
|
channelUpdate: [ChannelTypes, ChannelTypes];
|
||||||
debug: [string];
|
debug: [string];
|
||||||
warn: [string];
|
warn: [string];
|
||||||
disconnect: [any, number];
|
disconnect: [any, number];
|
||||||
@@ -2177,7 +2178,7 @@ declare module 'discord.js' {
|
|||||||
roleCreate: [Role];
|
roleCreate: [Role];
|
||||||
roleDelete: [Role];
|
roleDelete: [Role];
|
||||||
roleUpdate: [Role, Role];
|
roleUpdate: [Role, Role];
|
||||||
typingStart: [TextBasedChannelTypes | PartialChannel, User | PartialUser];
|
typingStart: [TextBasedChannelTypes | PartialDMChannel, User | PartialUser];
|
||||||
userUpdate: [User | PartialUser, User | PartialUser];
|
userUpdate: [User | PartialUser, User | PartialUser];
|
||||||
voiceStateUpdate: [VoiceState, VoiceState];
|
voiceStateUpdate: [VoiceState, VoiceState];
|
||||||
webhookUpdate: [TextChannel];
|
webhookUpdate: [TextChannel];
|
||||||
@@ -2761,14 +2762,34 @@ declare module 'discord.js' {
|
|||||||
type PresenceResolvable = Presence | UserResolvable | Snowflake;
|
type PresenceResolvable = Presence | UserResolvable | Snowflake;
|
||||||
|
|
||||||
type Partialize<T> = {
|
type Partialize<T> = {
|
||||||
|
readonly client: Client;
|
||||||
|
readonly createdAt: Date;
|
||||||
|
readonly createdTimestamp: number;
|
||||||
|
deleted: boolean;
|
||||||
id: string;
|
id: string;
|
||||||
partial: true;
|
partial: true;
|
||||||
fetch(): Promise<T>;
|
fetch(): Promise<T>;
|
||||||
} & {
|
} & {
|
||||||
[K in keyof Omit<T, 'id' | 'partial'>]: T[K] | null;
|
[K in keyof Omit<T,
|
||||||
|
'client' |
|
||||||
|
'createdAt' |
|
||||||
|
'createdTimestamp' |
|
||||||
|
'id' |
|
||||||
|
'partial' |
|
||||||
|
'fetch'>
|
||||||
|
// tslint:disable-next-line:ban-types
|
||||||
|
]: T[K] extends Function ? T[K] : T[K] | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface PartialChannel extends Partialize<ChannelTypes> {}
|
interface PartialDMChannel extends Partialize<DMChannel> {
|
||||||
|
lastMessage: null;
|
||||||
|
lastMessageID: undefined;
|
||||||
|
messages: MessageManager;
|
||||||
|
recipient: User | PartialUser;
|
||||||
|
type: 'dm';
|
||||||
|
readonly typing: boolean;
|
||||||
|
readonly typingCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
interface PartialChannelData {
|
interface PartialChannelData {
|
||||||
id?: number;
|
id?: number;
|
||||||
@@ -2784,8 +2805,30 @@ declare module 'discord.js' {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PartialGuildMember extends Partialize<GuildMember> {}
|
interface PartialGuildMember extends Partialize<GuildMember> {
|
||||||
interface PartialMessage extends Partialize<Message> {}
|
readonly bannable: boolean;
|
||||||
|
readonly displayColor: number;
|
||||||
|
readonly displayHexColor: string;
|
||||||
|
readonly displayName: string;
|
||||||
|
guild: Guild;
|
||||||
|
joinedAt: null;
|
||||||
|
joinedTimestamp: null;
|
||||||
|
readonly kickable: boolean;
|
||||||
|
readonly permissions: GuildMember['permissions'];
|
||||||
|
readonly roles: GuildMember['roles'];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PartialMessage extends Partialize<Message> {
|
||||||
|
attachments: Message['attachments'];
|
||||||
|
channel: Message['channel'];
|
||||||
|
readonly deletable: boolean;
|
||||||
|
readonly editable: boolean;
|
||||||
|
mentions: Message['mentions'];
|
||||||
|
readonly pinnable: boolean;
|
||||||
|
reactions: Message['reactions'];
|
||||||
|
system: boolean;
|
||||||
|
readonly url: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface PartialRoleData extends RoleData {
|
interface PartialRoleData extends RoleData {
|
||||||
id?: number;
|
id?: number;
|
||||||
@@ -2793,7 +2836,11 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION';
|
type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION';
|
||||||
|
|
||||||
interface PartialUser extends Partialize<User> {}
|
interface PartialUser extends Partialize<User> {
|
||||||
|
discriminator: undefined;
|
||||||
|
username: undefined;
|
||||||
|
readonly tag: null;
|
||||||
|
}
|
||||||
|
|
||||||
type PresenceStatus = ClientPresenceStatus | 'offline';
|
type PresenceStatus = ClientPresenceStatus | 'offline';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user