update to discord-player-v6 #76

Merged
Anri merged 30 commits from feat/music-v6 into main 2023-03-11 20:36:25 +01:00
Showing only changes of commit f2997dfab1 - Show all commits

View file

@ -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,
}))
);
},
};