forked from luisfun/discord-hono
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ed76b5
commit 863e984
Showing
20 changed files
with
1,121 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
import type { APICommandAutocompleteInteractionResponseCallbackData } from 'discord-api-types/v10' | ||
import { Builder } from './utils' | ||
import type { APICommandAutocompleteInteractionResponseCallbackData } from "discord-api-types/v10"; | ||
import { Builder } from "./utils"; | ||
|
||
export class Autocomplete extends Builder<APICommandAutocompleteInteractionResponseCallbackData> { | ||
#search: string | ||
#search: string; | ||
constructor(search?: string | number) { | ||
super({}) | ||
this.#search = search?.toString() || '' | ||
} | ||
choices = (...e: Required<APICommandAutocompleteInteractionResponseCallbackData>['choices']) => { | ||
const choices = e.filter(e2 => { | ||
if (e2.name.includes(this.#search)) return true | ||
if (Object.values(e2.name_localizations || {}).some(e3 => e3?.includes(this.#search))) return true | ||
if (e2.value.toString().includes(this.#search)) return true | ||
return false | ||
}) | ||
if (choices.length > 25) choices.length = 25 | ||
return this.a({ choices }) | ||
super({}); | ||
this.#search = search?.toString() || ""; | ||
} | ||
choices = ( | ||
...e: Required<APICommandAutocompleteInteractionResponseCallbackData>["choices"] | ||
) => { | ||
const choices = e.filter((e2) => { | ||
if (e2.name.includes(this.#search)) return true; | ||
if ( | ||
Object.values(e2.name_localizations || {}).some((e3) => | ||
e3?.includes(this.#search) | ||
) | ||
) | ||
return true; | ||
if (e2.value.toString().includes(this.#search)) return true; | ||
return false; | ||
}); | ||
if (choices.length > 25) choices.length = 25; | ||
return this.a({ choices }); | ||
}; | ||
} |
Oops, something went wrong.