Add separate instructions for URL filename entries

This commit is contained in:
Maciej Pędzich 2023-01-28 12:43:06 +01:00
parent 90f6b9b617
commit 4ea19f6d3e

41
bot.ts
View File

@ -125,31 +125,43 @@ export const bot: ApplicationFunction = (app) => {
identifiedPlaylistsText = `### ✅ These playlists have been indentified:\n${playlistLinks}`; identifiedPlaylistsText = `### ✅ These playlists have been indentified:\n${playlistLinks}`;
} }
let renameRequiredText = ''; let onlyRenameRequiredText = '';
const entriesToRename = playlistLookupResults.filter( const entriesToOnlyRename = playlistLookupResults.filter(
({ found, filename }) => ({ found, filename }) =>
found && found &&
(filename.includes(siQueryStart) || getPlaylistIdFromUrl(filename)) filename.includes(siQueryStart) &&
!getPlaylistIdFromUrl(filename)
); );
if (entriesToRename.length > 0) { if (entriesToOnlyRename.length > 0) {
const renameList = entriesToRename const renameList = entriesToOnlyRename
.map(({ filename }) => { .map(({ filename }) => {
const playlistIdFromPossibleUrl = getPlaylistIdFromUrl(filename); const filenameWithoutRegistryPath =
const filenameWithoutPath =
removeRegistryPathFromFilename(filename); removeRegistryPathFromFilename(filename);
const targetFilename = const [targetFilename] =
playlistIdFromPossibleUrl || filenameWithoutRegistryPath.split(siQueryStart);
filenameWithoutPath.split(siQueryStart)[0];
return `- From ${filenameWithoutPath} to **${targetFilename}**`; return `- From \`${filenameWithoutRegistryPath}\` to **${targetFilename}**`;
}) })
.join('\n'); .join('\n');
successText = ''; successText = '';
reviewEvent = 'REQUEST_CHANGES'; reviewEvent = 'REQUEST_CHANGES';
renameRequiredText = `### ⚠️ These entries have to be renamed:\n${renameList}`; onlyRenameRequiredText = `### ⚠️ You have to rename these entries:\n${renameList}`;
}
let urlEntriesToRenameText = '';
const urlFilenameEntries = playlistLookupResults.filter(
({ found, filename }) => {
found && getPlaylistIdFromUrl(filename);
}
);
if (urlFilenameEntries.length > 0) {
successText = '';
reviewEvent = 'REQUEST_CHANGES';
urlEntriesToRenameText = `### ⚠️ It looks like you've tried pasting playlist URL(s) for certain entries.\nBefore you try again, you'll have to remove the \`https:\` folder. If you don't know how to grab a playlist ID from a link, use [this tool](https://spotifyplaylistarchive.com/get-playlist-id).`;
} }
let notFoundText = ''; let notFoundText = '';
@ -164,12 +176,13 @@ export const bot: ApplicationFunction = (app) => {
successText = ''; successText = '';
reviewEvent = 'REQUEST_CHANGES'; reviewEvent = 'REQUEST_CHANGES';
notFoundText = `### ❌ Playlists for these entries don't exist:\n${renameList}`; notFoundText = `### ❌ These entries don't point to any existing public playlists:\n${renameList}`;
} }
const reviewBody = [ const reviewBody = [
identifiedPlaylistsText, identifiedPlaylistsText,
renameRequiredText, onlyRenameRequiredText,
urlEntriesToRenameText,
notFoundText, notFoundText,
successText successText
] ]