fix: select menu not found

This commit is contained in:
Elysia 2023-03-16 23:41:10 +07:00
parent b44663cd47
commit 5cc8aeffad
2 changed files with 10 additions and 2 deletions

View File

@ -1133,7 +1133,14 @@ class Message extends Base {
const menuAll = this.components const menuAll = this.components
.flatMap(row => row.components) .flatMap(row => row.components)
.filter(b => .filter(b =>
['STRING_SELECT', 'USER_SELECT', 'ROLE_SELECT', 'MENTIONABLE_SELECT', 'CHANNEL_SELECT'].includes(b.type), [
'STRING_SELECT',
'USER_SELECT',
'ROLE_SELECT',
'MENTIONABLE_SELECT',
'CHANNEL_SELECT',
'SELECT_MENU',
].includes(b.type),
); );
if (menuAll.length == 0) throw new TypeError('MENU_NOT_FOUND'); if (menuAll.length == 0) throw new TypeError('MENU_NOT_FOUND');
if (menuID) { if (menuID) {
@ -1142,7 +1149,7 @@ class Message extends Base {
menuID = menuAll[0]; menuID = menuAll[0];
} }
} }
if (!menuID.type.includes('_SELECT')) throw new TypeError('MENU_NOT_FOUND'); if (!menuID.type.includes('SELECT')) throw new TypeError('MENU_NOT_FOUND');
return menuID.select(this, Array.isArray(menuID) ? menuID : options); return menuID.select(this, Array.isArray(menuID) ? menuID : options);
} }
// //

View File

@ -293,6 +293,7 @@ class MessageSelectMenu extends BaseMessageComponent {
}); });
const parseValues = value => { const parseValues = value => {
switch (this.type) { switch (this.type) {
case 'SELECT_MENU':
case 'STRING_SELECT': { case 'STRING_SELECT': {
if (typeof value !== 'string') throw new TypeError('[INVALID_VALUE] Please pass a string value'); if (typeof value !== 'string') throw new TypeError('[INVALID_VALUE] Please pass a string value');
const value_ = this.options.find(obj => obj.value === value || obj.label === value); const value_ = this.options.find(obj => obj.value === value || obj.label === value);