Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Interaction channel type should be GuildTextBasedChannels when in guild #6998

Merged
merged 7 commits into from
Dec 1, 2021
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
APIApplicationCommandPermission,
APIAuditLogChange,
APIButtonComponent,
APIChannel,
APIEmbed,
APIEmoji,
APIInteractionDataResolvedChannel,
Expand Down Expand Up @@ -1190,7 +1191,7 @@ export class Interaction<Cached extends CacheType = CacheType> extends Base {
private readonly _cacheType: Cached;
protected constructor(client: Client, data: RawInteractionData);
public applicationId: Snowflake;
public readonly channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
public readonly channel: CacheTypeReducer<Cached, GuildTextBasedChannel, APIInteractionDataResolvedChannel>;
iCrawl marked this conversation as resolved.
Show resolved Hide resolved
public channelId: Snowflake | null;
public readonly createdAt: Date;
public readonly createdTimestamp: number;
Expand Down Expand Up @@ -1515,7 +1516,6 @@ export class MessageCollector extends Collector<Snowflake, Message> {

export class MessageComponentInteraction<Cached extends CacheType = CacheType> extends Interaction<Cached> {
protected constructor(client: Client, data: RawMessageComponentInteractionData);
public readonly channel: CacheTypeReducer<Cached, TextBasedChannels | null>;
public readonly component: CacheTypeReducer<
Cached,
MessageActionRowComponent,
Expand Down
2 changes: 2 additions & 0 deletions typings/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,10 @@ client.on('interactionCreate', async interaction => {
// @ts-expect-error
assertType<CommandInteraction<'cached'>>(interaction);
assertType<Interaction>(interaction);
assertType<GuildTextBasedChannel>(interaction.channel);
} else if (interaction.inRawGuild()) {
assertType<APIInteractionGuildMember>(interaction.member);
assertType<APIInteractionDataResolvedChannel>(interaction.channel);
// @ts-expect-error
consumeCachedInteraction(interaction);
} else {
Expand Down