make iterable

This commit is contained in:
baz 2024-07-13 22:22:30 +01:00
parent e73ceee074
commit 2e97bab0f5
2 changed files with 21 additions and 21 deletions

View File

@ -22,17 +22,17 @@ module.exports = {
const changelogEntries = await getChangelog(userDatabaseEntry.id);
let desc = '';
for (const entry of changelogEntries) {
const game = await checkGameStorageId(entry.gameId);
for (let i = 0; i < changelogEntries.length; i++) {
const game = await checkGameStorageId(changelogEntries[i].gameId);
if (entry.newStatus == 'planning') {
desc = desc.concat(`:pencil: planned **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (entry.newStatus == 'playing') {
desc = desc.concat(`:video_game: started playing **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (entry.newStatus == 'beat') {
desc = desc.concat(`:white_check_mark: beat **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (!entry.newStatus) {
desc = desc.concat(`:x: deleted **${game.name}** from **${entry.oldStatus}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
if (changelogEntries[i].newStatus == 'planning') {
desc = desc.concat(`:pencil: planned **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (changelogEntries[i].newStatus == 'playing') {
desc = desc.concat(`:video_game: started playing **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (changelogEntries[i].newStatus == 'beat') {
desc = desc.concat(`:white_check_mark: beat **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (!changelogEntries[i].newStatus) {
desc = desc.concat(`:x: deleted **${game.name}** from **${changelogEntries[i].oldStatus}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
}
}

View File

@ -10,18 +10,18 @@ module.exports = {
const changelogEntries = await getAllChangelog();
let desc = '';
for (const entry of changelogEntries) {
const game = await checkGameStorageId(entry.gameId);
const user = await getUserFromId(entry.userId);
for (let i = 0; i < changelogEntries.length; i++) {
const game = await checkGameStorageId(changelogEntries[i].gameId);
const user = await getUserFromId(changelogEntries[i].userId);
if (entry.newStatus == 'planning') {
desc = desc.concat(`:pencil: *${user.username}* planned **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (entry.newStatus == 'playing') {
desc = desc.concat(`:video_game: *${user.username}* started playing **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (entry.newStatus == 'beat') {
desc = desc.concat(`:white_check_mark: *${user.username}* beat **${game.name}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (!entry.newStatus) {
desc = desc.concat(`:x: *${user.username}* deleted **${game.name}** from **${entry.oldStatus}** *(${entry.createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
if (changelogEntries[i].newStatus == 'planning') {
desc = desc.concat(`:pencil: *${user.username}* planned **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (changelogEntries[i].newStatus == 'playing') {
desc = desc.concat(`:video_game: *${user.username}* started playing **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (changelogEntries[i].newStatus == 'beat') {
desc = desc.concat(`:white_check_mark: *${user.username}* beat **${game.name}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
} else if (!changelogEntries[i].newStatus) {
desc = desc.concat(`:x: *${user.username}* deleted **${game.name}** from **${changelogEntries[i].oldStatus}** *(${changelogEntries[i].createdAt.toLocaleDateString('en-GB', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '/')})*\n`);
}
}