Open
Description
Which package is this bug report for?
discord.js
Issue description
When fetching an invite from a guild the client is not in, the guild of an invite is an InviteGuild
, and the channel is handled as such:
discord.js/packages/discord.js/src/structures/Invite.js
Lines 176 to 186 in f6da949
With that understood, imagine an invite was created in a text channel that the client was not in. Fetching this invite would yield the guild to be an InviteGuild
and the channel being a TextChannel
. A text channel's guild is typed as Guild
, but this is incorrect—this.guild
is an InviteGuild
. The type is wrong.
Might be easier to tackle after #10888.
Code sample
import {
Client,
GatewayIntentBits,
Events,
TextChannel,
Guild,
InviteGuild,
} from "discord.js";
const client = new Client({ intents: GatewayIntentBits.Guilds });
client.on(Events.ClientReady, async () => {
const invite = await client.fetchInvite("https://discord.gg/djs");
console.log((invite.channel as TextChannel).guild instanceof Guild); // false.
console.log((invite.channel as TextChannel).guild instanceof InviteGuild); // true.
});
void client.login();
Versions
- discord.js f6da949
- Node.js 22.13.1
Issue priority
Low (slightly annoying)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds