mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 22:15:29 +00:00
fix: Improvement to play command autocomplete search
This commit is contained in:
1 parent
912080e8d4
commit
f59055807f
1 file changed
+6
-1
@@ -30,10 +30,11 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const searchResults = await player.search(query);
|
const searchResults = await player.search(query);
|
||||||
|
let response = [];
|
||||||
|
|
||||||
logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);
|
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:
|
name:
|
||||||
`${track.title} [Author: ${track.author}]`.length > 100
|
`${track.title} [Author: ${track.author}]`.length > 100
|
||||||
? `${track.title}`.slice(0, 100)
|
? `${track.title}`.slice(0, 100)
|
||||||
@@ -41,6 +42,10 @@ module.exports = {
|
|||||||
value: track.url
|
value: track.url
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (!response || response.length === 0) {
|
||||||
|
return interaction.respond([]);
|
||||||
|
}
|
||||||
|
|
||||||
return interaction.respond(response);
|
return interaction.respond(response);
|
||||||
},
|
},
|
||||||
execute: async ({ interaction }) => {
|
execute: async ({ interaction }) => {
|
||||||
|
|||||||
Reference in new issue
Block a user