Skip to content

Commit

Permalink
types(Message): remove & this from #inGuild typeguard (#8704)
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Oct 5, 2022
1 parent a7eab50 commit c0f7a1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/discord.js/typings/index.d.ts
Expand Up @@ -1750,7 +1750,7 @@ export class Message<InGuild extends boolean = boolean> extends Base {
public toJSON(): unknown;
public toString(): string;
public unpin(reason?: string): Promise<Message<InGuild>>;
public inGuild(): this is Message<true> & this;
public inGuild(): this is Message<true>;
}

export class AttachmentBuilder {
Expand Down
5 changes: 5 additions & 0 deletions packages/discord.js/typings/index.test-d.ts
Expand Up @@ -309,6 +309,11 @@ declare const assertIsMessage: (m: Promise<Message>) => void;

client.on('messageCreate', async message => {
const { client, channel } = message;

if (!message.inGuild() && message.partial) {
expectNotType<never>(message);
}

expectType<Client<true>>(client);
assertIsMessage(channel.send('string'));
assertIsMessage(channel.send({}));
Expand Down

0 comments on commit c0f7a1a

Please sign in to comment.