Fix crash due to value response of autocompletion (#111)
Max value of .value field is 100 Reviewed-on: #111 Co-authored-by: Mylloon <kennel.anri@tutanota.com> Co-committed-by: Mylloon <kennel.anri@tutanota.com>
This commit is contained in:
parent
86c46316cf
commit
e8a7174a4e
1 changed files with 11 additions and 3 deletions
|
@ -160,6 +160,9 @@ export default {
|
|||
loc_default?.get(`c_${filename}_opt1_name`) as string,
|
||||
true
|
||||
);
|
||||
|
||||
const limit_value_discord = 100;
|
||||
|
||||
if (query) {
|
||||
/* Since Discord wanna receive a response within 3 secs and results is async
|
||||
* and can take longer than that, exception of type 'Unknown interaction' (10062)
|
||||
|
@ -190,9 +193,12 @@ export default {
|
|||
|
||||
// If tracks found
|
||||
if (tracks.length > 0) {
|
||||
// Slice the list if needed
|
||||
if (tracks.length > 25) {
|
||||
tracks = tracks.slice(0, 25);
|
||||
tracks = tracks
|
||||
// Assure that URL is under the limit of Discord
|
||||
.filter((v) => v.url.length < limit_value_discord)
|
||||
// Slice the list if needed to the 25 first results
|
||||
.slice(0, 25);
|
||||
}
|
||||
|
||||
// Returns a list of songs with their title and author
|
||||
|
@ -223,6 +229,8 @@ export default {
|
|||
);
|
||||
}
|
||||
}
|
||||
return interaction.respond([{ name: loc.get("c_play9"), value: query }]);
|
||||
return interaction.respond([
|
||||
{ name: loc.get("c_play9"), value: query.slice(0, limit_value_discord) },
|
||||
]);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue