fix: friend invite

This commit is contained in:
Elysia 2024-01-30 14:44:38 +07:00
parent 7dd33bd946
commit bbe0399245
3 changed files with 7 additions and 7 deletions

View File

@ -523,7 +523,7 @@ class Client extends BaseClient {
*/
/**
* Join this Guild using this invite
* Join this Guild / GroupDMChannel using this invite
* @param {InviteResolvable} invite Invite code or URL
* @param {AcceptInviteOptions} [options={ bypassOnboarding: true, bypassVerify: true }] Options
* @returns {Promise<Guild|DMChannel|GroupDMChannel>}
@ -614,7 +614,7 @@ class Client extends BaseClient {
}
return guild;
} else {
return this.channels.cache.has(i.channelId);
return this.channels.cache.has(i.channelId || data.channel?.id);
}
}

View File

@ -193,16 +193,16 @@ class Invite extends Base {
if ('channel_id' in data) {
/**
* The channel's id this invite is for
* @type {Snowflake}
* @type {?Snowflake}
*/
this.channelId = data.channel_id;
this.channel = this.client.channels.cache.get(data.channel_id);
}
if ('channel' in data) {
if ('channel' in data && data.channel !== null) {
/**
* The channel this invite is for
* @type {Channel}
* @type {?Channel}
*/
this.channel ??= this.client.channels._add(data.channel, this.guild, { cache: false });
this.channelId ??= data.channel.id;

4
typings/index.d.ts vendored
View File

@ -1728,8 +1728,8 @@ export class InteractionWebhook extends PartialWebhookMixin() {
export class Invite extends Base {
private constructor(client: Client, data: RawInviteData);
public channel: NonThreadGuildBasedChannel | GroupDMChannel;
public channelId: Snowflake;
public channel?: NonThreadGuildBasedChannel | GroupDMChannel;
public channelId?: Snowflake;
public code: string;
public readonly deletable: boolean;
public readonly createdAt: Date | null;