Add play autocompletion
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
All checks were successful
ci/woodpecker/push/publish Pipeline was successful
This commit is contained in:
parent
cdce2494c5
commit
f2997dfab1
1 changed files with 22 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { SlashCommandBuilder } from "@discordjs/builders";
|
import { SlashCommandBuilder } from "@discordjs/builders";
|
||||||
import {
|
import {
|
||||||
|
AutocompleteInteraction,
|
||||||
ChatInputCommandInteraction,
|
ChatInputCommandInteraction,
|
||||||
Client,
|
Client,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
|
@ -35,6 +36,7 @@ export default {
|
||||||
.setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "")
|
.setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "")
|
||||||
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
.setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true))
|
||||||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`))
|
||||||
|
.setAutocomplete(true)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -148,4 +150,24 @@ export default {
|
||||||
content: `⏱️ | \`${title}\` ${loc.get("c_play5")}.`,
|
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,
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue