mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix: Prevent crash on no select menu option (#8881)
* fix: no crash on no option * refactor: consistency in ?? Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -10,19 +10,21 @@ const MessageComponentInteraction = require('./MessageComponentInteraction');
|
|||||||
class ChannelSelectMenuInteraction extends MessageComponentInteraction {
|
class ChannelSelectMenuInteraction extends MessageComponentInteraction {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
|
const { resolved, values } = data.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of the selected channel ids
|
* An array of the selected channel ids
|
||||||
* @type {Snowflake[]}
|
* @type {Snowflake[]}
|
||||||
*/
|
*/
|
||||||
this.values = data.data.values ?? [];
|
this.values = values ?? [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of the selected channels
|
* Collection of the selected channels
|
||||||
* @type {Collection<Snowflake, Channel|APIChannel>}
|
* @type {Collection<Snowflake, Channel|APIChannel>}
|
||||||
*/
|
*/
|
||||||
this.channels = new Collection();
|
this.channels = new Collection();
|
||||||
for (const channel of Object.values(data.data.resolved.channels)) {
|
|
||||||
|
for (const channel of Object.values(resolved?.channels ?? {})) {
|
||||||
this.channels.set(channel.id, this.client.channels._add(channel, this.guild) ?? channel);
|
this.channels.set(channel.id, this.client.channels._add(channel, this.guild) ?? channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ const Events = require('../util/Events');
|
|||||||
class MentionableSelectMenuInteraction extends MessageComponentInteraction {
|
class MentionableSelectMenuInteraction extends MessageComponentInteraction {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
|
const { resolved, values } = data.data;
|
||||||
|
const { members, users, roles } = resolved ?? {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of the selected user and role ids
|
* An array of the selected user and role ids
|
||||||
* @type {Snowflake[]}
|
* @type {Snowflake[]}
|
||||||
*/
|
*/
|
||||||
this.values = data.data.values ?? [];
|
this.values = values ?? [];
|
||||||
|
|
||||||
const { members, users, roles } = data.data.resolved ?? {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of the selected users
|
* Collection of the selected users
|
||||||
|
|||||||
@@ -10,19 +10,21 @@ const MessageComponentInteraction = require('./MessageComponentInteraction');
|
|||||||
class RoleSelectMenuInteraction extends MessageComponentInteraction {
|
class RoleSelectMenuInteraction extends MessageComponentInteraction {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
|
const { resolved, values } = data.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of the selected role ids
|
* An array of the selected role ids
|
||||||
* @type {Snowflake[]}
|
* @type {Snowflake[]}
|
||||||
*/
|
*/
|
||||||
this.values = data.data.values ?? [];
|
this.values = values ?? [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of the selected roles
|
* Collection of the selected roles
|
||||||
* @type {Collection<Snowflake, Role|APIRole>}
|
* @type {Collection<Snowflake, Role|APIRole>}
|
||||||
*/
|
*/
|
||||||
this.roles = new Collection();
|
this.roles = new Collection();
|
||||||
for (const role of Object.values(data.data.resolved.roles)) {
|
|
||||||
|
for (const role of Object.values(resolved?.roles ?? {})) {
|
||||||
this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
|
this.roles.set(role.id, this.guild?.roles._add(role) ?? role);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ const Events = require('../util/Events');
|
|||||||
class UserSelectMenuInteraction extends MessageComponentInteraction {
|
class UserSelectMenuInteraction extends MessageComponentInteraction {
|
||||||
constructor(client, data) {
|
constructor(client, data) {
|
||||||
super(client, data);
|
super(client, data);
|
||||||
|
const { resolved, values } = data.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of the selected user ids
|
* An array of the selected user ids
|
||||||
* @type {Snowflake[]}
|
* @type {Snowflake[]}
|
||||||
*/
|
*/
|
||||||
this.values = data.data.values ?? [];
|
this.values = values ?? [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of the selected users
|
* Collection of the selected users
|
||||||
@@ -30,24 +31,19 @@ class UserSelectMenuInteraction extends MessageComponentInteraction {
|
|||||||
*/
|
*/
|
||||||
this.members = new Collection();
|
this.members = new Collection();
|
||||||
|
|
||||||
for (const user of Object.values(data.data.resolved.users)) {
|
for (const user of Object.values(resolved?.users ?? {})) {
|
||||||
this.users.set(user.id, this.client.users._add(user));
|
this.users.set(user.id, this.client.users._add(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.data.resolved.members) {
|
for (const [id, member] of Object.entries(resolved?.members ?? {})) {
|
||||||
for (const [id, member] of Object.entries(data.data.resolved.members)) {
|
const user = resolved.users[id];
|
||||||
const user = data.data.resolved.users[id];
|
|
||||||
if (!user) {
|
|
||||||
this.client.emit(
|
|
||||||
Events.Debug,
|
|
||||||
`[UserSelectMenuInteraction] Received a member without a user, skipping ${id}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
continue;
|
if (!user) {
|
||||||
}
|
this.client.emit(Events.Debug, `[UserSelectMenuInteraction] Received a member without a user, skipping ${id}`);
|
||||||
|
continue;
|
||||||
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.members.set(id, this.guild?.members._add({ user, ...member }) ?? { user, ...member });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user