chore: merge branch dev
to main
#200
1 changed files with 21 additions and 17 deletions
|
@ -193,6 +193,9 @@ export default {
|
||||||
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
|
const query = interaction.options.getString(loc_default!.get(`c_${filename}_opt1_name`)!, true);
|
||||||
|
|
||||||
const limit_value_discord = 100;
|
const limit_value_discord = 100;
|
||||||
|
const limit_element_discord = 25;
|
||||||
|
|
||||||
|
const query_discord = query.slice(0, limit_value_discord);
|
||||||
|
|
||||||
if (query) {
|
if (query) {
|
||||||
/* Since Discord wanna receive a response within 3 secs and results is async
|
/* Since Discord wanna receive a response within 3 secs and results is async
|
||||||
|
@ -208,7 +211,7 @@ export default {
|
||||||
|
|
||||||
/* Create a race between a timeout and the search
|
/* Create a race between a timeout and the search
|
||||||
* At the end, Discord will always receive a response */
|
* At the end, Discord will always receive a response */
|
||||||
let tracks = await Promise.race([
|
const tracks = await Promise.race([
|
||||||
delay,
|
delay,
|
||||||
player.search(query, {
|
player.search(query, {
|
||||||
requestedBy: interaction.user,
|
requestedBy: interaction.user,
|
||||||
|
@ -225,17 +228,12 @@ export default {
|
||||||
|
|
||||||
// If tracks found
|
// If tracks found
|
||||||
if (tracks.length > 0) {
|
if (tracks.length > 0) {
|
||||||
if (tracks.length > 25) {
|
const payload = tracks
|
||||||
tracks = tracks
|
// Assure that URL is under the limit of Discord
|
||||||
// Assure that URL is under the limit of Discord
|
.filter((v) => v.url.length < limit_value_discord)
|
||||||
.filter((v) => v.url.length < limit_value_discord)
|
// Slice the list to respect the limit of Discord
|
||||||
// Slice the list if needed to the 25 first results
|
.slice(0, limit_element_discord - 1)
|
||||||
.slice(0, 25);
|
.map((t) => {
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a list of songs with their title and author
|
|
||||||
return interaction.respond(
|
|
||||||
tracks.map((t) => {
|
|
||||||
let title = t.title;
|
let title = t.title;
|
||||||
let author = t.author;
|
let author = t.author;
|
||||||
let name = `${title} • ${author}`;
|
let name = `${title} • ${author}`;
|
||||||
|
@ -257,12 +255,18 @@ export default {
|
||||||
name,
|
name,
|
||||||
value: t.url,
|
value: t.url,
|
||||||
};
|
};
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
|
payload.unshift({
|
||||||
|
name: query_discord,
|
||||||
|
value: query_discord,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Returns a list of songs with their title and author
|
||||||
|
return interaction.respond(payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return interaction.respond([
|
|
||||||
{ name: loc.get("c_play9"), value: query.slice(0, limit_value_discord) },
|
return interaction.respond([{ name: loc.get("c_play9"), value: query_discord }]);
|
||||||
]);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue