diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index 7821691..d2e2dc5 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -1,5 +1,6 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { + AutocompleteInteraction, ChatInputCommandInteraction, Client, EmbedBuilder, @@ -35,6 +36,7 @@ export default { .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) + .setAutocomplete(true) ) ); }, @@ -148,4 +150,24 @@ export default { content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`, }); }, + + autocomplete: async (interaction: AutocompleteInteraction) => { + const loc_default = interaction.client.locales.get(interaction.client.config.default_lang); + const filename = getFilename(__filename); + + const player = useMasterPlayer() as Player; + const query = interaction.options.getString( + loc_default?.get(`c_${filename}_opt1_name`) as string, + true + ); + const results = await player.search(query); + + // Returns a list of songs with their title + return interaction.respond( + results.tracks.slice(0, 10).map((t) => ({ + name: t.title, + value: t.url, + })) + ); + }, };