fix: Improvement to play command autocomplete search

This commit is contained in:
Marius Begby committed 2023-07-27 21:58:09 +02:00
1 parent 912080e8d4
commit f59055807f
1 file changed
+6 -1
+6 -1
View File
@@ -30,10 +30,11 @@ module.exports = {
return;
}
const searchResults = await player.search(query);
let response = [];
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);
let response = searchResults.tracks.slice(0, 5).map((track) => ({
response = searchResults.tracks.slice(0, 5).map((track) => ({
name:
`${track.title} [Author: ${track.author}]`.length > 100
? `${track.title}`.slice(0, 100)
@@ -41,6 +42,10 @@ module.exports = {
value: track.url
}));
if (!response || response.length === 0) {
return interaction.respond([]);
}
return interaction.respond(response);
},
execute: async ({ interaction }) => {