diff --git a/src/lib/utils.js b/src/lib/utils.js index 014a8a8..4911a0d 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -160,7 +160,13 @@ async function hastebin(body) { } hf.selectionMessages = hf.selectionMessages || new Eris.Collection(); -async function selectionMessage(msg, heading, options, timeout = 30000) { +async function selectionMessage( + msg, + heading, + options, + timeout = 30000, + maxItems = 1 +) { const data = { content: heading, allowedMentions: { @@ -177,6 +183,7 @@ async function selectionMessage(msg, heading, options, timeout = 30000) { type: 3, custom_id: msg.id, options: [], + max_values: maxItems, }, ], }, @@ -193,15 +200,15 @@ async function selectionMessage(msg, heading, options, timeout = 30000) { }, ], }; - options.slice(0, 20).forEach((value) => { + options.slice(0, 25).forEach((value) => { data.components[0].components[0].options.push({ label: value.display, value: value.key, description: value.description, }); }); - if (options.length > 20) { - data.content += `\n\nDisplaying 20/${options.length} results`; + if (options.length > 25) { + data.content += `\n\nDisplaying 25/${options.length} results`; } const displayMessage = await msg.channel.createMessage(data); @@ -235,9 +242,17 @@ async function selectionMessage(msg, heading, options, timeout = 30000) { displayMessage.delete(); - const result = options.filter( - (opt) => opt.key == interaction.data.values[0] - )[0].value; + let result; + + if (maxItems > 1) { + result = options + .filter((opt) => interaction.data.values.includes(opt.key)) + .map((opt) => opt.value); + } else { + result = options.filter( + (opt) => opt.key == interaction.data.values[0] + )[0].value; + } resolve(result); }