Skip to content

fix: Miscellaneous fixes #9445

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

Merged
merged 11 commits into from
May 1, 2023
Merged
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ client.login('token');
## Links

- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website))
- [Documentation](https://discord.js.org/#/docs)
- [Documentation](https://discord.js.org/docs)
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v13.html), including updated and removed items in the library.
- [discord.js Discord server](https://discord.gg/djs)
Expand All @@ -116,7 +116,7 @@ client.login('token');
## Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
[documentation](https://discord.js.org/#/docs).
[documentation](https://discord.js.org/docs).
See [the contribution guide](https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR.

## Help
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## [View the documentation here.](https://discord.js.org/#/docs)
## [View the documentation here.](https://discord.js.org/docs)
2 changes: 1 addition & 1 deletion src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,5 +617,5 @@ module.exports = Client;

/**
* @external Collection
* @see {@link https://discord.js.org/#/docs/collection/main/class/Collection}
* @see {@link https://discord.js.org/docs/packages/collection/main/Collection:Class}
*/
4 changes: 2 additions & 2 deletions src/managers/ApplicationCommandManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ module.exports = ApplicationCommandManager;

/**
* @external SlashCommandBuilder
* @see {@link https://discord.js.org/#/docs/builders/main/class/SlashCommandBuilder}
* @see {@link https://discord.js.org/docs/packages/builders/main/SlashCommandBuilder:Class}
*/

/**
* @external ContextMenuCommandBuilder
* @see {@link https://discord.js.org/#/docs/builders/main/class/ContextMenuCommandBuilder}
* @see {@link https://discord.js.org/docs/packages/builders/main/ContextMenuCommandBuilder:Class}
*/
6 changes: 3 additions & 3 deletions src/managers/ChannelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ 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);
}
return existing;
}

const channel = Channel.create(this.client, data, guild, { allowUnknownGuild, fromInteraction });
const channel = Channel.create(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}`);
Expand Down
15 changes: 14 additions & 1 deletion src/structures/CategoryChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ const GuildChannel = require('./GuildChannel');
* @extends {GuildChannel}
*/
class CategoryChannel extends GuildChannel {
/**
* The id of the parent of this channel.
* @name CategoryChannel#parentId
* @type {null}
*/

/**
* The parent of this channel.
* @name CategoryChannel#parent
* @type {null}
* @readonly
*/

/**
* Channels that are a part of this category
* @type {Collection<Snowflake, GuildChannel>}
Expand All @@ -18,7 +31,7 @@ class CategoryChannel extends GuildChannel {

/**
* Sets the category parent of this channel.
* <warn>It is not currently possible to set the parent of a CategoryChannel.</warn>
* <warn>It is not possible to set the parent of a CategoryChannel.</warn>
* @method setParent
* @memberof CategoryChannel
* @instance
Expand Down
4 changes: 2 additions & 2 deletions src/structures/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Channel extends Base {
return this.type === 'GUILD_DIRECTORY';
}

static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
static create(client, data, guild, { allowUnknownGuild } = {}) {
CategoryChannel ??= require('./CategoryChannel');
DMChannel ??= require('./DMChannel');
NewsChannel ??= require('./NewsChannel');
Expand Down Expand Up @@ -238,7 +238,7 @@ class Channel extends Base {
case ChannelTypes.GUILD_NEWS_THREAD:
case ChannelTypes.GUILD_PUBLIC_THREAD:
case ChannelTypes.GUILD_PRIVATE_THREAD: {
channel = new ThreadChannel(guild, data, client, fromInteraction);
channel = new ThreadChannel(guild, data, client);
if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { resolveAutoArchiveMaxLimit } = require('../util/Util');
* @implements {TextBasedChannel}
*/
class ThreadChannel extends Channel {
constructor(guild, data, client, fromInteraction = false) {
constructor(guild, data, client) {
super(guild?.client ?? client, data, false);

/**
Expand All @@ -41,7 +41,7 @@ class ThreadChannel extends Channel {
* @type {ThreadMemberManager}
*/
this.members = new ThreadMemberManager(this);
if (data) this._patch(data, fromInteraction);
if (data) this._patch(data);
}

_patch(data, partial = false) {
Expand Down
6 changes: 3 additions & 3 deletions src/structures/interfaces/TextBasedChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class TextBasedChannel {
* @property {boolean} [tts=false] Whether or not the message should be spoken aloud
* @property {string} [nonce=''] The nonce for the message
* @property {string} [content=''] The content for the message
* @property {MessageEmbed[]|APIEmbed[]} [embeds] The embeds for the message
* @property {Array<(MessageEmbed|APIEmbed)>} [embeds] The embeds for the message
* (see [here](https://discord.com/developers/docs/resources/channel#embed-object) for more details)
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
* (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
* @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] Files to send with the message
* @property {MessageActionRow[]|MessageActionRowOptions[]} [components]
* @property {Array<(FileOptions|BufferResolvable|MessageAttachment[])>} [files] Files to send with the message
* @property {Array<(MessageActionRow|MessageActionRowOptions)>} [components]
* Action rows containing interactive components for the message (buttons, select menus)
* @property {MessageAttachment[]} [attachments] Attachments to send in the message
*/
Expand Down
2 changes: 1 addition & 1 deletion src/util/LimitedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { TypeError } = require('../errors/DJSError.js');
* @typedef {Function} SweepFilter
* @param {LimitedCollection} collection The collection being swept
* @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`,
* See {@link [Collection#sweep](https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=sweep)}
* See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)}
* for the definition of this function.
*/

Expand Down
6 changes: 3 additions & 3 deletions src/util/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class Options extends null {
}

/**
* The default settings passed to {@link Options.cacheWithLimits}.
* The default settings passed to {@link ClientOptions.makeCache}.
* The caches that this changes are:
* * `MessageManager` - Limit to 200 messages
* * `ChannelManager` - Sweep archived threads
Expand Down Expand Up @@ -281,11 +281,11 @@ class Options extends null {
}

/**
* The default settings passed to {@link Options.sweepers} (for v14).
* The default settings passed to {@link ClientOptions.sweepers}.
* The sweepers that this changes are:
* * `threads` - Sweep archived threads every hour, removing those archived more than 4 hours ago
* <info>If you want to keep default behavior and add on top of it you can use this object and add on to it, e.g.
* `sweepers: { ...Options.defaultSweeperSettings, messages: { interval: 300, lifetime: 600 } })`</info>
* `sweepers: { ...Options.defaultSweeperSettings, messages: { interval: 300, lifetime: 600 } }`</info>
* @type {SweeperOptions}
*/
Options.defaultSweeperSettings = {
Expand Down
2 changes: 1 addition & 1 deletion src/util/Sweepers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { TypeError } = require('../errors/DJSError.js');
/**
* @typedef {Function} GlobalSweepFilter
* @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`,
* See {@link [Collection#sweep](https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=sweep)}
* See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/main/Collection:Class#sweep)}
* for the definition of this function.
*/

Expand Down
6 changes: 4 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ export type CategoryChannelTypes = ExcludeEnum<

export class CategoryChannel extends GuildChannel {
public readonly children: Collection<Snowflake, Exclude<NonThreadGuildBasedChannel, CategoryChannel>>;
public static parent: null;
public parentId: null;
public type: 'GUILD_CATEGORY';

public createChannel<T extends Exclude<CategoryChannelTypes, 'GUILD_STORE' | ChannelTypes.GUILD_STORE>>(
Expand Down Expand Up @@ -2592,7 +2594,7 @@ export class TextInputComponent extends BaseMessageComponent {
}

export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhooks', 'createWebhook', 'setNSFW']) {
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client, fromInteraction?: boolean);
private constructor(guild: Guild, data?: RawThreadChannelData, client?: Client);
public archived: boolean | null;
public readonly archivedAt: Date | null;
public archiveTimestamp: number | null;
Expand Down Expand Up @@ -6387,7 +6389,7 @@ export type GuildBasedChannel = Extract<AnyChannel, { guild: Guild }>;

export type NonThreadGuildBasedChannel = Exclude<GuildBasedChannel, ThreadChannel>;

export type GuildTextBasedChannel = Exclude<Extract<GuildBasedChannel, TextBasedChannel>, ForumChannel>;
export type GuildTextBasedChannel = Extract<GuildBasedChannel, TextBasedChannel>;

export type TextChannelResolvable = Snowflake | TextChannel;

Expand Down