Compare commits

..

6 Commits

Author SHA1 Message Date
Jiralite
6a0cd82566 chore(builders): increase @discordjs/builders version 2026-03-31 18:35:30 +01:00
Jiralite
2eaec32414 chore(builders): release @discordjs/builders@1.14.1 2026-03-31 18:25:46 +01:00
ducktrshessami
6e45ddc067 fix: actually accept rest in RadioGroup/CheckBoxGroupBuilder#setOptions (#11472) 2026-03-31 19:21:57 +02:00
Vlad Frangu
eee6f948ee chore(discord.js): release discord.js@14.26.0 2026-03-31 11:30:58 +03:00
Qjuh
45bd430c0d feat: allow partial DMChannel without client user (#11462)
* feat(DMChannel): allow partial DMChannel without client user

* chore: apply code review comments

* chore: apply code review suggestion
2026-03-27 14:34:33 +01:00
Vlad Frangu
d20e10305b chore(builders): release @discordjs/builders@1.14.0 2026-03-23 02:02:08 +02:00
11 changed files with 80 additions and 18 deletions

View File

@@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file.
# [@discordjs/builders@1.14.1](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.14.0...@discordjs/builders@1.14.1) - (2026-03-31)
## Bug Fixes
- Actually accept rest in RadioGroup/CheckBoxGroupBuilder#setOptions (#11472) ([6e45ddc](https://github.com/discordjs/discord.js/commit/6e45ddc067816b01d6676f04faea54d34469fefc))
# [@discordjs/builders@1.14.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.13.1...@discordjs/builders@1.14.0) - (2026-03-22)
## Documentation
- **builders:** Edited docs to correctly link to splice (#11430) ([ec5d921](https://github.com/discordjs/discord.js/commit/ec5d921b75255cf28fd572a91e715b37305f4cf8))
## Features
- **builders:** Add checkbox, checkboxgroup, and radiogroup builders (#11410) ([ca7719e](https://github.com/discordjs/discord.js/commit/ca7719e822e02a83e5a7b769de3c5fd615dc24fd))
# [@discordjs/builders@1.13.1](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.13.0...@discordjs/builders@1.13.1) - (2025-11-30)
## Bug Fixes

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@discordjs/builders",
"version": "1.13.1",
"version": "1.14.1",
"description": "A set of builders that you can use when creating your bot",
"scripts": {
"test": "vitest run",

View File

@@ -86,7 +86,7 @@ export class CheckboxGroupBuilder extends ComponentBuilder<APICheckboxGroupCompo
*
* @param options - The options to use
*/
public setOptions(options: RestOrArray<APICheckboxGroupOption | CheckboxGroupOptionBuilder>) {
public setOptions(...options: RestOrArray<APICheckboxGroupOption | CheckboxGroupOptionBuilder>) {
return this.spliceOptions(0, this.options.length, ...options);
}

View File

@@ -84,7 +84,7 @@ export class RadioGroupBuilder extends ComponentBuilder<APIRadioGroupComponent>
*
* @param options - The options to use
*/
public setOptions(options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>) {
public setOptions(...options: RestOrArray<APIRadioGroupOption | RadioGroupOptionBuilder>) {
return this.spliceOptions(0, this.options.length, ...options);
}

View File

@@ -2,6 +2,26 @@
All notable changes to this project will be documented in this file.
# [14.26.0](https://github.com/discordjs/discord.js/compare/14.25.1...14.26.0) - (2026-03-31)
## Bug Fixes
- Remove manage messages check for pinnable (#11453) ([1a0da18](https://github.com/discordjs/discord.js/commit/1a0da18b3611a31553fd5250b6f882b755d8d003))
- **DJSError:** Differentiate error type (#11295) ([f5b3f84](https://github.com/discordjs/discord.js/commit/f5b3f842e39ec1f211a0017fadb683ae3b372e02))
## Features
- Allow partial DMChannel without client user (#11462) ([45bd430](https://github.com/discordjs/discord.js/commit/45bd430c0d55ddb98380ea320fab9dc56211e07a))
- Modal radio group and checkbox components for v14 (#11437) ([b42e499](https://github.com/discordjs/discord.js/commit/b42e4994109ee83f3e329e810cc8733cf4176dbe))
## Refactor
- **DJSError:** Prefer `this.constructor.name` (#11294) ([e32f0c1](https://github.com/discordjs/discord.js/commit/e32f0c141a4ef17383f7a868e26c26a2878fb4f2))
## Typings
- BroadcastEval overload order (#11422) ([16d70b9](https://github.com/discordjs/discord.js/commit/16d70b9232559f505f4d6c1a5b1122ebbac5e35d))
# [14.25.1](https://github.com/discordjs/discord.js/compare/14.25.0...14.25.1) - (2025-11-21)
## Bug Fixes

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "discord.js",
"version": "14.25.1",
"version": "14.26.0",
"description": "A powerful library for interacting with the Discord API",
"scripts": {
"test": "pnpm run docs:test && pnpm run test:typescript",

View File

@@ -33,10 +33,16 @@ class GenericAction {
const payloadData = {};
const id = data.channel_id ?? data.id;
if (!('recipients' in data)) {
// Try to resolve the recipient, but do not add the client user.
if ('recipients' in data) {
// Try to resolve the recipient, but do not add if already existing in recipients.
const recipient = data.author ?? data.user ?? { id: data.user_id };
if (recipient.id !== this.client.user.id) payloadData.recipients = [recipient];
if (!data.recipients.some(existingRecipient => recipient.id === existingRecipient.id)) {
payloadData.recipients = [...data.recipients, recipient];
}
} else {
// Try to resolve the recipient.
const recipient = data.author ?? data.user ?? { id: data.user_id };
payloadData.recipients = [recipient];
}
if (id !== undefined) payloadData.id = id;

View File

@@ -21,7 +21,9 @@ class InteractionCreateAction extends Action {
const client = this.client;
// Resolve and cache partial channels for Interaction#channel getter
const channel = data.channel && this.getChannel(data.channel);
const channel =
data.channel &&
this.getChannel({ ...data.channel, ...('recipients' in data.channel ? { user: data.user } : undefined) });
// Do not emit this for interactions that cache messages that are non-text-based.
let InteractionClass;

View File

@@ -41,9 +41,12 @@ class UserManager extends CachedManager {
* @private
*/
dmChannel(userId) {
const expectedRecipientIds = [userId, this.client.user.id];
return (
this.client.channels.cache.find(channel => channel.type === ChannelType.DM && channel.recipientId === userId) ??
null
this.client.channels.cache.find(
channel =>
channel.type === ChannelType.DM && channel.recipientIds.every(id => expectedRecipientIds.includes(id)),
) ?? null
);
}

View File

@@ -30,16 +30,18 @@ class DMChannel extends BaseChannel {
super._patch(data);
if (data.recipients) {
const recipient = data.recipients[0];
/**
* The recipient's id
* @type {Snowflake}
* The recipients' ids
* @type {Snowflake[]}
*/
this.recipientId = recipient.id;
this.recipientIds = [
...new Set([...(this.recipientIds ?? []), ...data.recipients.map(recipient => recipient.id)]),
];
if ('username' in recipient || this.client.options.partials.includes(Partials.User)) {
this.client.users._add(recipient);
for (const recipient of data.recipients) {
if ('username' in recipient || this.client.options.partials.includes(Partials.User)) {
this.client.users._add(recipient);
}
}
}
@@ -71,6 +73,18 @@ class DMChannel extends BaseChannel {
return this.lastMessageId === undefined;
}
/**
* The recipient's id.
* <info>For DMChannel the client user is not a part of this might return a wrong id.
* This will return `null` in the next major version.</info>
* @type {Snowflake}
* @readonly
*/
get recipientId() {
// To not be a breaking change this returns the arbitrary first id if this is not a DMChannel with the client user
return this.recipientIds.find(recipientId => recipientId !== this.client.user.id) ?? this.recipientIds[0];
}
/**
* The recipient on the other end of the DM
* @type {?User}

View File

@@ -1514,7 +1514,8 @@ export interface DMChannel extends Omit<
export class DMChannel extends BaseChannel {
private constructor(client: Client<true>, data?: RawDMChannelData);
public flags: Readonly<ChannelFlagsBitField>;
public recipientId: Snowflake;
public get recipientId(): Snowflake;
public recipientIds: Snowflake[];
public get recipient(): User | null;
public type: ChannelType.DM;
public fetch(force?: boolean): Promise<this>;