Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
fix: enforce max character length of 100 for name and value in autoco…
Browse files Browse the repository at this point in the history
…mplete
  • Loading branch information
mariusbegby committed Jul 28, 2023
1 parent 7428323 commit 724f407
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/commands/player/lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ module.exports = {
`${track.title} [Artist: ${track.author}]`.length > 100
? `${track.title}`.slice(0, 100)
: `${track.title} [Author: ${track.author}]`,
value: track.title
value: track.title.slice(0, 100)
}));
} else {
response = [
{
name: `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`,
value: lyricsResult.title
name: `${lyricsResult.title} [Artist: ${lyricsResult.artist.name}]`.slice(0, 100),
value: lyricsResult.title.slice(0, 100)
}
];
}
Expand Down
19 changes: 12 additions & 7 deletions src/commands/player/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@ module.exports = {

logger.debug(`[Shard ${interaction.guild.shardId}] Autocomplete search responded for query: ${query}`);

response = searchResults.tracks.slice(0, 5).map((track) => ({
name:
`${track.title} [Author: ${track.author}]`.length > 100
? `${track.title}`.slice(0, 100)
: `${track.title} [Author: ${track.author}]`,
value: track.url
}));
response = searchResults.tracks.slice(0, 5).map((track) => {
if (track.url.length > 100) {
track.url = track.title.slice(0, 100);
}
return {
name:
`${track.title} [Author: ${track.author}]`.length > 100
? `${track.title}`.slice(0, 100)
: `${track.title} [Author: ${track.author}]`,
value: track.url
};
});

if (!response || response.length === 0) {
return interaction.respond([]);
Expand Down

0 comments on commit 724f407

Please # to comment.