mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-22 16:55:30 +01:00
Autocomplete Suggestion Improvements for Favorites Use Command (#956)
Co-authored-by: Max Isom <codetheweb@users.noreply.github.com>
This commit is contained in:
parent
6b6066c06a
commit
3998b06386
|
@ -6,7 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.4.0] - 2023-07-19
|
||||
### Fixed
|
||||
- Autocomplete suggestion search for `favorites use` command is no longer case-sensitive
|
||||
- Autocomplete suggestion results for `favorites use` could return >25 results which Discord's API does not support
|
||||
|
||||
## [2.4.0] - 2023-07-19
|
||||
### Added
|
||||
|
|
|
@ -89,14 +89,16 @@ export default class implements Command {
|
|||
},
|
||||
});
|
||||
|
||||
let results = query === '' ? favorites : favorites.filter(f => f.name.startsWith(query));
|
||||
let results = query === '' ? favorites : favorites.filter(f => f.name.toLowerCase().startsWith(query.toLowerCase()));
|
||||
|
||||
if (subcommand === 'remove') {
|
||||
// Only show favorites that user is allowed to remove
|
||||
results = interaction.member?.user.id === interaction.guild?.ownerId ? results : results.filter(r => r.authorId === interaction.member!.user.id);
|
||||
}
|
||||
|
||||
await interaction.respond(results.map(r => ({
|
||||
// Limit results to 25 maximum per Discord limits
|
||||
const trimmed = results.length > 25 ? results.slice(0, 25) : results;
|
||||
await interaction.respond(trimmed.map(r => ({
|
||||
name: r.name,
|
||||
value: r.name,
|
||||
})));
|
||||
|
|
Loading…
Reference in a new issue