This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
4119574
commit 4750325
Showing
25 changed files
with
307 additions
and
262 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 |
---|---|---|
@@ -1,29 +1,34 @@ | ||
import Fuse from "fuse.js"; | ||
import { getCommands } from "../utils/getCached"; | ||
import { Autocomplete } from "../Autocomplete"; | ||
import * as commands from "../commands"; | ||
|
||
export const help = { | ||
export const help: Autocomplete = { | ||
name: "help", | ||
execute: async (interaction) => { | ||
const { value } = interaction.options.getFocused(true); | ||
const commands = await getCommands( | ||
interaction.guild?.commands, | ||
interaction.client.application?.commands | ||
); | ||
const value = interaction.options.getFocused(); | ||
const commandValues = Object.values(commands); | ||
|
||
const fuse = new Fuse( | ||
commands?.map(({ name }) => ({ | ||
name, | ||
value: name, | ||
commandValues?.map(({ data, helpText }) => ({ | ||
name: data.name, | ||
short: helpText.short, | ||
long: helpText.long, | ||
})), | ||
{ keys: ["name"] } | ||
{ | ||
keys: [ | ||
{ name: "name", weight: 3 }, | ||
{ name: "short", weight: 2 }, | ||
{ name: "long", weight: 1 }, | ||
], | ||
} | ||
); | ||
commands?.map(({ name }) => ({ | ||
name, | ||
value: name, | ||
})); | ||
|
||
const query = fuse.search(value.toString()); | ||
|
||
interaction.respond(query.map((result) => result.item)); | ||
interaction.respond( | ||
query.map((result) => ({ | ||
name: result.item.name, | ||
value: result.item.name, | ||
})) | ||
); | ||
}, | ||
}; |
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
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
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
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
Oops, something went wrong.