mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13: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 isDMBased(): this is PartialGroupDMChannel | DMChannel | PartialDMChannel;
|
||||
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;
|
||||
@@ -1075,6 +1075,7 @@ export class DMChannel extends TextBasedChannelMixin(Channel, ['bulkDelete']) {
|
||||
public get recipient(): User | null;
|
||||
public type: ChannelType.DM;
|
||||
public fetch(force?: boolean): Promise<this>;
|
||||
public toString(): UserMention;
|
||||
}
|
||||
|
||||
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 setPosition(position: number, options?: SetChannelPositionOptions): Promise<this>;
|
||||
public isTextBased(): this is GuildBasedChannel & TextBasedChannel;
|
||||
public toString(): ChannelMention;
|
||||
}
|
||||
|
||||
export class GuildEmoji extends BaseGuildEmoji {
|
||||
@@ -1960,6 +1962,7 @@ export class PartialGroupDMChannel extends Channel {
|
||||
public icon: string | null;
|
||||
public recipients: PartialRecipient[];
|
||||
public iconURL(options?: ImageURLOptions): string | null;
|
||||
public toString(): ChannelMention;
|
||||
}
|
||||
|
||||
export class PermissionOverwrites extends Base {
|
||||
@@ -2464,6 +2467,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) {
|
||||
public setLocked(locked?: boolean, reason?: string): Promise<ThreadChannel>;
|
||||
public setName(name: string, reason?: string): Promise<ThreadChannel>;
|
||||
public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>;
|
||||
public toString(): ChannelMention;
|
||||
}
|
||||
|
||||
export class ThreadMember extends Base {
|
||||
|
||||
@@ -120,6 +120,9 @@ import {
|
||||
GuildBanManager,
|
||||
GuildBan,
|
||||
MessageManager,
|
||||
ChannelMention,
|
||||
UserMention,
|
||||
PartialGroupDMChannel,
|
||||
} from '.';
|
||||
import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||
import { UnsafeButtonBuilder, UnsafeEmbedBuilder, UnsafeSelectMenuBuilder } from '@discordjs/builders';
|
||||
@@ -1533,3 +1536,16 @@ EmbedBuilder.from(embedData);
|
||||
|
||||
declare const embedComp: Embed;
|
||||
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