mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-25 21:10:10 +00:00
Compare commits
7 Commits
@discordjs
...
14.23.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
083f6abb38 | ||
|
|
5cc13b735c | ||
|
|
1e4d1dc04f | ||
|
|
177d81f596 | ||
|
|
bf4cfeb4bf | ||
|
|
11b236ff65 | ||
|
|
1d5b9837de |
@@ -2,6 +2,20 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
# [14.23.2](https://github.com/discordjs/discord.js/compare/14.23.1...14.23.2) - (2025-10-09)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **ModalSubmitInteraction:** Better resolving of components (#11162) ([5cc13b7](https://github.com/discordjs/discord.js/commit/5cc13b735c78384a3488da527985cded92f67d41))
|
||||
- Handle DM modals ([1e4d1dc](https://github.com/discordjs/discord.js/commit/1e4d1dc04f7dabfb0575441957a6278675f02871))
|
||||
|
||||
# [14.23.1](https://github.com/discordjs/discord.js/compare/14.23.0...14.23.1) - (2025-10-08)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
- **ModalSubmitInteraction:** Resolve crash on handling populated select menus (#11158) ([11b236f](https://github.com/discordjs/discord.js/commit/11b236ff6539f91f11caa3d5a2cc7ae23070aaec))
|
||||
- Ending uncached polls (#11157) ([1d5b983](https://github.com/discordjs/discord.js/commit/1d5b9837de4036ca6f07f22f714f534463cc35ec))
|
||||
|
||||
# [14.23.0](https://github.com/discordjs/discord.js/compare/14.22.1...14.23.0) - (2025-10-08)
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "discord.js",
|
||||
"version": "14.23.0",
|
||||
"version": "14.23.2",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"scripts": {
|
||||
"test": "pnpm run docs:test && pnpm run test:typescript",
|
||||
@@ -66,7 +66,7 @@
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.12.0",
|
||||
"@discordjs/builders": "^1.12.1",
|
||||
"@discordjs/collection": "1.5.3",
|
||||
"@discordjs/formatters": "^0.6.1",
|
||||
"@discordjs/rest": "workspace:^",
|
||||
|
||||
@@ -80,7 +80,10 @@ class ModalSubmitInteraction extends BaseInteraction {
|
||||
* @type {Array<ActionRowModalData | LabelModalData | TextDisplayModalData>}
|
||||
*/
|
||||
this.components = data.data.components?.map(component =>
|
||||
ModalSubmitInteraction.transformComponent(component, data.data.resolved),
|
||||
ModalSubmitInteraction.transformComponent(component, data.data.resolved, {
|
||||
client: this.client,
|
||||
guild: this.guild,
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -121,14 +124,17 @@ class ModalSubmitInteraction extends BaseInteraction {
|
||||
* Transforms component data to discord.js-compatible data
|
||||
* @param {*} rawComponent The data to transform
|
||||
* @param {APIInteractionDataResolved} [resolved] The resolved data for the interaction
|
||||
* @param {*} [extra] Extra data required for the transformation
|
||||
* @returns {ModalData[]}
|
||||
*/
|
||||
static transformComponent(rawComponent, resolved) {
|
||||
static transformComponent(rawComponent, resolved, { client, guild } = {}) {
|
||||
if ('components' in rawComponent) {
|
||||
return {
|
||||
type: rawComponent.type,
|
||||
id: rawComponent.id,
|
||||
components: rawComponent.components.map(component => this.transformComponent(component, resolved)),
|
||||
components: rawComponent.components.map(component =>
|
||||
this.transformComponent(component, resolved, { client, guild }),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -136,7 +142,7 @@ class ModalSubmitInteraction extends BaseInteraction {
|
||||
return {
|
||||
type: rawComponent.type,
|
||||
id: rawComponent.id,
|
||||
component: this.transformComponent(rawComponent.component, resolved),
|
||||
component: this.transformComponent(rawComponent.component, resolved, { client, guild }),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,33 +158,55 @@ class ModalSubmitInteraction extends BaseInteraction {
|
||||
|
||||
if (rawComponent.values) {
|
||||
data.values = rawComponent.values;
|
||||
|
||||
/* eslint-disable max-depth */
|
||||
if (resolved) {
|
||||
const resolveCollection = (resolvedData, resolver) => {
|
||||
const collection = new Collection();
|
||||
for (const value of data.values) {
|
||||
if (resolvedData?.[value]) {
|
||||
collection.set(value, resolver(resolvedData[value]));
|
||||
const { members, users, channels, roles } = resolved;
|
||||
const valueSet = new Set(rawComponent.values);
|
||||
|
||||
if (users) {
|
||||
data.users = new Collection();
|
||||
|
||||
for (const [id, user] of Object.entries(users)) {
|
||||
if (valueSet.has(id)) {
|
||||
data.users.set(id, client.users._add(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return collection.size ? collection : null;
|
||||
};
|
||||
if (channels) {
|
||||
data.channels = new Collection();
|
||||
|
||||
const users = resolveCollection(resolved.users, user => this.client.users._add(user));
|
||||
if (users) data.users = users;
|
||||
for (const [id, apiChannel] of Object.entries(channels)) {
|
||||
if (valueSet.has(id)) {
|
||||
data.channels.set(id, client.channels._add(apiChannel, guild) ?? apiChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const channels = resolveCollection(
|
||||
resolved.channels,
|
||||
channel => this.client.channels._add(channel, this.guild) ?? channel,
|
||||
);
|
||||
if (channels) data.channels = channels;
|
||||
if (members) {
|
||||
data.members = new Collection();
|
||||
|
||||
const members = resolveCollection(resolved.members, member => this.guild?.members._add(member) ?? member);
|
||||
if (members) data.members = members;
|
||||
for (const [id, member] of Object.entries(members)) {
|
||||
if (valueSet.has(id)) {
|
||||
const user = users?.[id];
|
||||
data.members.set(id, guild?.members._add({ user, ...member }) ?? member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const roles = resolveCollection(resolved.roles, role => this.guild?.roles._add(role) ?? role);
|
||||
if (roles) data.roles = roles;
|
||||
if (roles) {
|
||||
data.roles = new Collection();
|
||||
|
||||
for (const [id, role] of Object.entries(roles)) {
|
||||
if (valueSet.has(id)) {
|
||||
data.roles.set(id, guild?.roles._add(role) ?? role);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable max-depth */
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -164,7 +164,7 @@ class Poll extends Base {
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async end() {
|
||||
if (Date.now() > this.expiresTimestamp) {
|
||||
if (this.expiresTimestamp !== null && Date.now() > this.expiresTimestamp) {
|
||||
throw new DiscordjsError(ErrorCodes.PollAlreadyExpired);
|
||||
}
|
||||
|
||||
|
||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -932,8 +932,8 @@ importers:
|
||||
packages/discord.js:
|
||||
dependencies:
|
||||
'@discordjs/builders':
|
||||
specifier: ^1.12.0
|
||||
version: 1.12.0
|
||||
specifier: ^1.12.1
|
||||
version: 1.12.1
|
||||
'@discordjs/collection':
|
||||
specifier: 1.5.3
|
||||
version: 1.5.3
|
||||
@@ -2789,8 +2789,8 @@ packages:
|
||||
resolution: {integrity: sha512-4JINx4Rttha29f50PBsJo48xZXx/He5yaIWJRwVarhYAN947+S84YciHl+AIhQNRPAFkg8+5qFngEGtKxQDWXA==}
|
||||
engines: {node: '>=18.18.0'}
|
||||
|
||||
'@discordjs/builders@1.12.0':
|
||||
resolution: {integrity: sha512-jQ0m/fVOg6j3w2Rrzrg5VfqPpkslYNnpdTAyQzQXQ7S/5y0iScBnMlVZfu/AFLP9C34shQ4I+EpTGZV1VlN7RQ==}
|
||||
'@discordjs/builders@1.12.1':
|
||||
resolution: {integrity: sha512-C5iNx2PgNj5MTZZ3WZeybJ7N0erYVBGDQpNPHZ4rCD21n9DejLpmQDTI8nxxGm3NapS3QwYHKZtHBEVPWBhhVw==}
|
||||
engines: {node: '>=16.11.0'}
|
||||
|
||||
'@discordjs/collection@1.5.3':
|
||||
@@ -16321,7 +16321,7 @@ snapshots:
|
||||
tar-stream: 3.1.7
|
||||
which: 4.0.0
|
||||
|
||||
'@discordjs/builders@1.12.0':
|
||||
'@discordjs/builders@1.12.1':
|
||||
dependencies:
|
||||
'@discordjs/formatters': 0.6.1
|
||||
'@discordjs/util': 1.1.1
|
||||
|
||||
Reference in New Issue
Block a user