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

feat(BaseInteraction): Support new channel payload #9337

Merged
merged 5 commits into from Apr 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/discord.js/src/structures/BaseInteraction.js
Expand Up @@ -5,6 +5,7 @@ const { DiscordSnowflake } = require('@sapphire/snowflake');
const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v10');
const Base = require('./Base');
const { SelectMenuTypes } = require('../util/Constants');
const Partials = require('../util/Partials');
const PermissionsBitField = require('../util/PermissionsBitField');

/**
Expand Down Expand Up @@ -46,7 +47,18 @@ class BaseInteraction extends Base {
* The id of the channel this interaction was sent in
* @type {?Snowflake}
*/
this.channelId = data.channel_id ?? null;
this.channelId = data.channel?.id ?? null;

/**
* The channel this interaction was sent in.
* @type {?TextBasedChannels|APIChannel}
* @private
*/
this._channel =
(this.channelId && client.channels.cache.get(this.channelId)) ??
client.options.partials.includes(Partials.Channel)
? data.channel
: null;
Jiralite marked this conversation as resolved.
Show resolved Hide resolved

/**
* The id of the guild this interaction was sent in
Expand Down Expand Up @@ -159,7 +171,7 @@ class BaseInteraction extends Base {
* @readonly
*/
get channel() {
return this.client.channels.cache.get(this.channelId) ?? null;
return this._channel;
Jiralite marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down