Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
fix: Improvement to play command autocomplete search
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusbegby committed Jul 27, 2023
1 parent 912080e commit f590558
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/commands/player/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ 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)
: `${track.title} [Author: ${track.author}]`,
value: track.url
}));

if (!response || response.length === 0) {
return interaction.respond([]);
}

return interaction.respond(response);
},
execute: async ({ interaction }) => {
Expand Down

0 comments on commit f590558

Please sign in to comment.