Compare commits

..

2 Commits

Author SHA1 Message Date
github-actions[bot]
790ce1681c chore(main): release 1.2.1 (#148)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-10-03 11:53:45 -05:00
Evo
cbad7380e1 fix(autocomplete): now support multiple autocomplete options (#147) 2022-10-03 11:50:49 -05:00
4 changed files with 16 additions and 7 deletions

View File

@@ -1,5 +1,12 @@
# Changelog
## [1.2.1](https://github.com/sern-handler/handler/compare/v1.2.0...v1.2.1) (2022-10-03)
### Bug Fixes
* **autocomplete:** now support multiple autocomplete options ([#147](https://github.com/sern-handler/handler/issues/147)) ([cbad738](https://github.com/sern-handler/handler/commit/cbad7380e1993b96c643f365726457f63e4fbd5d))
## [1.2.0](https://github.com/sern-handler/handler/compare/v1.1.0...v1.2.0) (2022-09-28)

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@sern/handler",
"version": "1.2.0",
"version": "1.2.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@sern/handler",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"dependencies": {
"rxjs": "^7.5.6",

View File

@@ -1,6 +1,6 @@
{
"name": "@sern/handler",
"version": "1.2.0",
"version": "1.2.1",
"description": "A customizable, batteries-included, powerful discord.js framework to automate and streamline bot development.",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",

View File

@@ -1,12 +1,14 @@
import type { SernOptionsData } from '../structures/module';
import type { SernAutocompleteData, SernOptionsData } from '../structures/module';
import { ApplicationCommandOptionType, AutocompleteInteraction } from 'discord.js';
export default function treeSearch(
iAutocomplete: AutocompleteInteraction,
options: SernOptionsData[] | undefined,
) {
): SernAutocompleteData {
if (options === undefined) return undefined;
const _options = options.slice(); // required to prevent direct mutation of options
let autocompleteData: SernAutocompleteData;
while (_options.length > 0) {
const cur = _options.pop()!;
switch (cur.type) {
@@ -29,12 +31,12 @@ export default function treeSearch(
if (cur.autocomplete) {
const choice = iAutocomplete.options.getFocused(true);
if (cur.name === choice.name && cur.autocomplete) {
return cur;
autocompleteData = cur;
}
return undefined;
}
}
break;
}
}
return autocompleteData;
}