From 2e97bab0f57887a67fd4c63c0a36d651551c6685 Mon Sep 17 00:00:00 2001 From: baz Date: Sat, 13 Jul 2024 22:22:30 +0100 Subject: [PATCH] make iterable --- commands/100-games/changelog.js | 20 ++++++++++---------- commands/100-games/globalchangelog.js | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/commands/100-games/changelog.js b/commands/100-games/changelog.js index 0ed9d8c..73d30d3 100644 --- a/commands/100-games/changelog.js +++ b/commands/100-games/changelog.js @@ -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`); } } diff --git a/commands/100-games/globalchangelog.js b/commands/100-games/globalchangelog.js index ccb79c4..6bd205d 100644 --- a/commands/100-games/globalchangelog.js +++ b/commands/100-games/globalchangelog.js @@ -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`); } }