refactor: Remove fromInteraction in internal channel creation (#9335)

refactor: remove `fromInteraction`
This commit is contained in:
Jiralite
2023-04-14 22:29:27 +01:00
committed by GitHub
parent 02dfaf1aa2
commit 794abe8450
4 changed files with 10 additions and 11 deletions

View File

@@ -36,10 +36,10 @@ class ChannelManager extends CachedManager {
* @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);
if (existing) {
if (cache) existing._patch(data, fromInteraction);
if (cache) existing._patch(data);
guild?.channels?._add(existing);
if (ThreadChannelTypes.includes(existing.type)) {
existing.parent?.threads?._add(existing);
@@ -47,7 +47,7 @@ class ChannelManager extends CachedManager {
return existing;
}
const channel = createChannel(this.client, data, guild, { allowUnknownGuild, fromInteraction });
const channel = createChannel(this.client, data, guild, { allowUnknownGuild });
if (!channel) {
this.client.emit(Events.Debug, `Failed to find guild, or unknown type for channel ${data.id} ${data.type}`);

View File

@@ -14,7 +14,7 @@ const ChannelFlagsBitField = require('../util/ChannelFlagsBitField');
* @implements {TextBasedChannel}
*/
class ThreadChannel extends BaseChannel {
constructor(guild, data, client, fromInteraction = false) {
constructor(guild, data, client) {
super(guild?.client ?? client, data, false);
/**
@@ -40,10 +40,10 @@ class ThreadChannel extends BaseChannel {
* @type {ThreadMemberManager}
*/
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);
if ('message' in data) this.messages._add(data.message);
@@ -149,7 +149,7 @@ class ThreadChannel extends BaseChannel {
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
* @type {?number}

View File

@@ -23,7 +23,7 @@ const getForumChannel = lazy(() => require('../structures/ForumChannel'));
* @returns {Channel} Any kind of channel.
* @ignore
*/
function createChannel(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
function createChannel(client, data, guild, { allowUnknownGuild } = {}) {
let channel;
if (!data.guild_id && !guild) {
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.PublicThread:
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);
break;
}

View File

@@ -2944,7 +2944,7 @@ export class ThreadChannel<Forum extends boolean = boolean> extends TextBasedCha
'createWebhook',
'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 get archivedAt(): Date | null;
public archiveTimestamp: number | null;
@@ -3138,7 +3138,6 @@ export interface MappedComponentTypes {
export interface ChannelCreateOptions {
allowFromUnknownGuild?: boolean;
fromInteraction?: boolean;
}
export function createChannel(client: Client<true>, data: APIChannel, options?: ChannelCreateOptions): Channel;