mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
refactor: Remove fromInteraction in internal channel creation (#9335)
refactor: remove `fromInteraction`
This commit is contained in:
@@ -36,10 +36,10 @@ class ChannelManager extends CachedManager {
|
|||||||
* @name ChannelManager#cache
|
* @name ChannelManager#cache
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_add(data, guild, { cache = true, allowUnknownGuild = false, fromInteraction = false } = {}) {
|
_add(data, guild, { cache = true, allowUnknownGuild = false } = {}) {
|
||||||
const existing = this.cache.get(data.id);
|
const existing = this.cache.get(data.id);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
if (cache) existing._patch(data, fromInteraction);
|
if (cache) existing._patch(data);
|
||||||
guild?.channels?._add(existing);
|
guild?.channels?._add(existing);
|
||||||
if (ThreadChannelTypes.includes(existing.type)) {
|
if (ThreadChannelTypes.includes(existing.type)) {
|
||||||
existing.parent?.threads?._add(existing);
|
existing.parent?.threads?._add(existing);
|
||||||
@@ -47,7 +47,7 @@ class ChannelManager extends CachedManager {
|
|||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = createChannel(this.client, data, guild, { allowUnknownGuild, fromInteraction });
|
const channel = createChannel(this.client, data, guild, { allowUnknownGuild });
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
this.client.emit(Events.Debug, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`);
|
this.client.emit(Events.Debug, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const ChannelFlagsBitField = require('../util/ChannelFlagsBitField');
|
|||||||
* @implements {TextBasedChannel}
|
* @implements {TextBasedChannel}
|
||||||
*/
|
*/
|
||||||
class ThreadChannel extends BaseChannel {
|
class ThreadChannel extends BaseChannel {
|
||||||
constructor(guild, data, client, fromInteraction = false) {
|
constructor(guild, data, client) {
|
||||||
super(guild?.client ?? client, data, false);
|
super(guild?.client ?? client, data, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,10 +40,10 @@ class ThreadChannel extends BaseChannel {
|
|||||||
* @type {ThreadMemberManager}
|
* @type {ThreadMemberManager}
|
||||||
*/
|
*/
|
||||||
this.members = new ThreadMemberManager(this);
|
this.members = new ThreadMemberManager(this);
|
||||||
if (data) this._patch(data, fromInteraction);
|
if (data) this._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
_patch(data, partial = false) {
|
_patch(data) {
|
||||||
super._patch(data);
|
super._patch(data);
|
||||||
|
|
||||||
if ('message' in data) this.messages._add(data.message);
|
if ('message' in data) this.messages._add(data.message);
|
||||||
@@ -149,7 +149,7 @@ class ThreadChannel extends BaseChannel {
|
|||||||
this.lastPinTimestamp ??= null;
|
this.lastPinTimestamp ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('rate_limit_per_user' in data || !partial) {
|
if ('rate_limit_per_user' in data) {
|
||||||
/**
|
/**
|
||||||
* The rate limit per user (slowmode) for this thread in seconds
|
* The rate limit per user (slowmode) for this thread in seconds
|
||||||
* @type {?number}
|
* @type {?number}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const getForumChannel = lazy(() => require('../structures/ForumChannel'));
|
|||||||
* @returns {Channel} Any kind of channel.
|
* @returns {Channel} Any kind of channel.
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
function createChannel(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
|
function createChannel(client, data, guild, { allowUnknownGuild } = {}) {
|
||||||
let channel;
|
let channel;
|
||||||
if (!data.guild_id && !guild) {
|
if (!data.guild_id && !guild) {
|
||||||
if ((data.recipients && data.type !== ChannelType.GroupDM) || data.type === ChannelType.DM) {
|
if ((data.recipients && data.type !== ChannelType.GroupDM) || data.type === ChannelType.DM) {
|
||||||
@@ -59,7 +59,7 @@ function createChannel(client, data, guild, { allowUnknownGuild, fromInteraction
|
|||||||
case ChannelType.AnnouncementThread:
|
case ChannelType.AnnouncementThread:
|
||||||
case ChannelType.PublicThread:
|
case ChannelType.PublicThread:
|
||||||
case ChannelType.PrivateThread: {
|
case ChannelType.PrivateThread: {
|
||||||
channel = new (getThreadChannel())(guild, data, client, fromInteraction);
|
channel = new (getThreadChannel())(guild, data, client);
|
||||||
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -2944,7 +2944,7 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
|
|||||||
'createWebhook',
|
'createWebhook',
|
||||||
'setNSFW',
|
'setNSFW',
|
||||||
]) {
|
]) {
|
||||||
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client<true>, fromInteraction?: boolean);
|
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client<true>);
|
||||||
public archived: boolean | null;
|
public archived: boolean | null;
|
||||||
public get archivedAt(): Date | null;
|
public get archivedAt(): Date | null;
|
||||||
public archiveTimestamp: number | null;
|
public archiveTimestamp: number | null;
|
||||||
@@ -3138,7 +3138,6 @@ export interface MappedComponentTypes {
|
|||||||
|
|
||||||
export interface ChannelCreateOptions {
|
export interface ChannelCreateOptions {
|
||||||
allowFromUnknownGuild?: boolean;
|
allowFromUnknownGuild?: boolean;
|
||||||
fromInteraction?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createChannel(client: Client<true>, data: APIChannel, options?: ChannelCreateOptions): Channel;
|
export function createChannel(client: Client<true>, data: APIChannel, options?: ChannelCreateOptions): Channel;
|
||||||
|
|||||||
Reference in New Issue
Block a user