mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
types: fix return type of toString() on channels (#7836)
* types(DMChannel): `toString()` returns a `UserMention` * test: add more tests
This commit is contained in:
6
packages/discord.js/typings/index.d.ts
vendored
6
packages/discord.js/typings/index.d.ts
vendored
@@ -745,7 +745,7 @@ export abstract class Channel extends Base {
|
|||||||
public isTextBased(): this is TextBasedChannel;
|
public isTextBased(): this is TextBasedChannel;
|
||||||
public isDMBased(): this is PartialGroupDMChannel | DMChannel | PartialDMChannel;
|
public isDMBased(): this is PartialGroupDMChannel | DMChannel | PartialDMChannel;
|
||||||
public isVoiceBased(): this is VoiceBasedChannel;
|
public isVoiceBased(): this is VoiceBasedChannel;
|
||||||
public toString(): ChannelMention;
|
public toString(): ChannelMention | UserMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B;
|
export type If<T extends boolean, A, B = null> = T extends true ? A : T extends false ? B : A | B;
|
||||||
@@ -1075,6 +1075,7 @@ export class DMChannel extends TextBasedChannelMixin(Channel, ['bulkDelete']) {
|
|||||||
public get recipient(): User | null;
|
public get recipient(): User | null;
|
||||||
public type: ChannelType.DM;
|
public type: ChannelType.DM;
|
||||||
public fetch(force?: boolean): Promise<this>;
|
public fetch(force?: boolean): Promise<this>;
|
||||||
|
public toString(): UserMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Emoji extends Base {
|
export class Emoji extends Base {
|
||||||
@@ -1274,6 +1275,7 @@ export abstract class GuildChannel extends Channel {
|
|||||||
public setParent(channel: CategoryChannelResolvable | null, options?: SetParentOptions): Promise<this>;
|
public setParent(channel: CategoryChannelResolvable | null, options?: SetParentOptions): Promise<this>;
|
||||||
public setPosition(position: number, options?: SetChannelPositionOptions): Promise<this>;
|
public setPosition(position: number, options?: SetChannelPositionOptions): Promise<this>;
|
||||||
public isTextBased(): this is GuildBasedChannel & TextBasedChannel;
|
public isTextBased(): this is GuildBasedChannel & TextBasedChannel;
|
||||||
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GuildEmoji extends BaseGuildEmoji {
|
export class GuildEmoji extends BaseGuildEmoji {
|
||||||
@@ -1960,6 +1962,7 @@ export class PartialGroupDMChannel extends Channel {
|
|||||||
public icon: string | null;
|
public icon: string | null;
|
||||||
public recipients: PartialRecipient[];
|
public recipients: PartialRecipient[];
|
||||||
public iconURL(options?: ImageURLOptions): string | null;
|
public iconURL(options?: ImageURLOptions): string | null;
|
||||||
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PermissionOverwrites extends Base {
|
export class PermissionOverwrites extends Base {
|
||||||
@@ -2464,6 +2467,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) {
|
|||||||
public setLocked(locked?: boolean, reason?: string): Promise<ThreadChannel>;
|
public setLocked(locked?: boolean, reason?: string): Promise<ThreadChannel>;
|
||||||
public setName(name: string, reason?: string): Promise<ThreadChannel>;
|
public setName(name: string, reason?: string): Promise<ThreadChannel>;
|
||||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>;
|
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>;
|
||||||
|
public toString(): ChannelMention;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ThreadMember extends Base {
|
export class ThreadMember extends Base {
|
||||||
|
|||||||
@@ -120,6 +120,9 @@ import {
|
|||||||
GuildBanManager,
|
GuildBanManager,
|
||||||
GuildBan,
|
GuildBan,
|
||||||
MessageManager,
|
MessageManager,
|
||||||
|
ChannelMention,
|
||||||
|
UserMention,
|
||||||
|
PartialGroupDMChannel,
|
||||||
} from '.';
|
} from '.';
|
||||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||||
import { UnsafeButtonBuilder, UnsafeEmbedBuilder, UnsafeSelectMenuBuilder } from '@discordjs/builders';
|
import { UnsafeButtonBuilder, UnsafeEmbedBuilder, UnsafeSelectMenuBuilder } from '@discordjs/builders';
|
||||||
@@ -1533,3 +1536,16 @@ EmbedBuilder.from(embedData);
|
|||||||
|
|
||||||
declare const embedComp: Embed;
|
declare const embedComp: Embed;
|
||||||
EmbedBuilder.from(embedComp);
|
EmbedBuilder.from(embedComp);
|
||||||
|
|
||||||
|
declare const stageChannel: StageChannel;
|
||||||
|
declare const partialGroupDMChannel: PartialGroupDMChannel;
|
||||||
|
|
||||||
|
expectType<ChannelMention>(textChannel.toString());
|
||||||
|
expectType<ChannelMention>(voiceChannel.toString());
|
||||||
|
expectType<ChannelMention>(newsChannel.toString());
|
||||||
|
expectType<ChannelMention>(threadChannel.toString());
|
||||||
|
expectType<ChannelMention>(stageChannel.toString());
|
||||||
|
expectType<ChannelMention>(partialGroupDMChannel.toString());
|
||||||
|
expectType<UserMention>(dmChannel.toString());
|
||||||
|
expectType<UserMention>(user.toString());
|
||||||
|
expectType<UserMention>(guildMember.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user