Minor refactor and success message rewording

This commit is contained in:
Maciej Pędzich 2022-09-22 06:14:31 +02:00
parent 724a52a28e
commit da5b67a642

16
bot.ts
View File

@ -28,23 +28,19 @@ const bot: ApplicationFunction = (app) => {
event: 'REQUEST_CHANGES' | 'COMMENT' event: 'REQUEST_CHANGES' | 'COMMENT'
) => { ) => {
if (review_id) { if (review_id) {
const { data } = await context.octokit.pulls.updateReview({ await context.octokit.pulls.updateReview({
...workingRepo, ...workingRepo,
pull_number, pull_number,
review_id, review_id,
body body
}); });
return data.id;
} else { } else {
const { data } = await context.octokit.pulls.createReview({ await context.octokit.pulls.createReview({
...workingRepo, ...workingRepo,
pull_number, pull_number,
event, event,
body body
}); });
return data.id;
} }
}; };
@ -73,6 +69,7 @@ const bot: ApplicationFunction = (app) => {
const spotifyResponse = await fetch(url); const spotifyResponse = await fetch(url);
const found = spotifyResponse.status === 200; const found = spotifyResponse.status === 200;
let info: string | null = null; let info: string | null = null;
if (found) { if (found) {
@ -112,12 +109,11 @@ const bot: ApplicationFunction = (app) => {
}); });
const [existingReview] = priorReviews; const [existingReview] = priorReviews;
const canMergeMessage = `🎉 @${workingRepo.owner} can merge your pull request! 🎉`;
let identifiedPlaylistsText = ''; let identifiedPlaylistsText = '';
let renameRequiredText = ''; let renameRequiredText = '';
let notFoundText = ''; let notFoundText = '';
let successText = canMergeMessage; let successText = `🎉 @${workingRepo.owner} can merge your pull request! 🎉`;
let reviewEvent: 'REQUEST_CHANGES' | 'COMMENT' = 'COMMENT'; let reviewEvent: 'REQUEST_CHANGES' | 'COMMENT' = 'COMMENT';
if (validEntries.length > 0) { if (validEntries.length > 0) {
@ -173,7 +169,7 @@ const bot: ApplicationFunction = (app) => {
...workingRepo, ...workingRepo,
pull_number, pull_number,
review_id: existingReview.id, review_id: existingReview.id,
message: 'All new entries are now valid!' message: 'All new entries can be accepted!'
}); });
} }
} catch (error) { } catch (error) {
@ -183,7 +179,7 @@ const bot: ApplicationFunction = (app) => {
...workingRepo, ...workingRepo,
pull_number, pull_number,
event: 'COMMENT', event: 'COMMENT',
body: `Something went wrong while verifying new entries! @${workingRepo.owner} should handle it shortly...` body: `Something went wrong while validating new entries! @${workingRepo.owner} should handle it shortly...`
}); });
} }
} }