diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index d3b92dd80..1fa63b2cc 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -5,7 +5,7 @@ const { ChannelFlags, ChannelType, PermissionFlagsBits, Routes } = require('disc const { BaseChannel } = require('./BaseChannel'); const getThreadOnlyChannel = lazy(() => require('./ThreadOnlyChannel')); const TextBasedChannel = require('./interfaces/TextBasedChannel'); -const { DiscordjsError, DiscordjsRangeError, ErrorCodes } = require('../errors'); +const { DiscordjsRangeError, ErrorCodes } = require('../errors'); const GuildMessageManager = require('../managers/GuildMessageManager'); const ThreadMemberManager = require('../managers/ThreadMemberManager'); const ChannelFlagsBitField = require('../util/ChannelFlagsBitField'); @@ -31,6 +31,12 @@ class ThreadChannel extends BaseChannel { */ this.guildId = guild?.id ?? data.guild_id; + /** + * The id of the member who created this thread + * @type {Snowflake} + */ + this.ownerId = data.owner_id; + /** * A manager of the messages sent to this thread * @type {GuildMessageManager} @@ -121,16 +127,6 @@ class ThreadChannel extends BaseChannel { this._createdTimestamp ??= this.type === ChannelType.PrivateThread ? super.createdTimestamp : null; - if ('owner_id' in data) { - /** - * The id of the member who created this thread - * @type {?Snowflake} - */ - this.ownerId = data.owner_id; - } else { - this.ownerId ??= null; - } - if ('last_message_id' in data) { /** * The last message id sent in this thread, if one was sent @@ -300,10 +296,6 @@ class ThreadChannel extends BaseChannel { * @returns {Promise} */ async fetchOwner(options) { - if (!this.ownerId) { - throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'thread'); - } - const member = await this.members._fetchSingle({ ...options, member: this.ownerId }); return member; } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 099346cfd..a2c4d3da8 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3376,7 +3376,7 @@ export class ThreadChannel extends BaseCha public totalMessageSent: number | null; public members: ThreadMemberManager; public name: string; - public ownerId: Snowflake | null; + public ownerId: Snowflake; public get parent(): If | null; public parentId: Snowflake | null; public rateLimitPerUser: number | null;