| 74 | } |
| 75 | |
| 76 | export async function checkForPatchNotes() { |
| 77 | // Check if any patch notes have not been read |
| 78 | const dbPatchNotes = QueryUtils.selectAllPatchNotes(); |
| 79 | const unreadFileNames = fs.readdirSync("./patch-notes") |
| 80 | .filter(fileNames => !dbPatchNotes.some(dbPatchNote => dbPatchNote.fileName == fileNames)); |
| 81 | if (unreadFileNames.length === 0) return; |
| 82 | |
| 83 | // Use dynamic import to load the .ts file |
| 84 | const patchNotesChannelId = process.env.PATCH_NOTES_CHANNEL_ID; |
| 85 | if (!patchNotesChannelId) return; |
| 86 | const patchNotesChannel = CLIENT.channels.cache.get(patchNotesChannelId) as TextChannel; |
| 87 | for (const fileName of unreadFileNames) { |
| 88 | const { embeds } = await import(`../../patch-notes/${fileName}`); |
| 89 | |
| 90 | // wait for console confirmation |
| 91 | let userInput = null; |
| 92 | while (!["1", "2", "3"].includes(userInput)) { |
| 93 | console.log(""); |
| 94 | console.log(`Patch notes for '${fileName}' have not been sent. Enter a number to continue:`); |
| 95 | console.log("[1] send patch notes to patch notes channel"); |
| 96 | console.log("[2] mark patch note as already sent"); |
| 97 | console.log("[3] skip"); |
| 98 | userInput = (await new Promise(resolve => process.stdin.once("data", resolve))).toString().trim(); |
| 99 | } |
| 100 | if (userInput === "1") { |
| 101 | await patchNotesChannel.send({ embeds }); |
| 102 | QueryUtils.insertPatchNotes({ fileName }); |
| 103 | console.log(`Sent ${fileName}. Continuing...`); |
| 104 | } |
| 105 | else if (userInput === "2") { |
| 106 | QueryUtils.insertPatchNotes({ fileName }); |
| 107 | console.log(`Marked '${fileName}' as sent. Continuing...`); |
| 108 | } |
| 109 | else { |
| 110 | console.log("Continuing..."); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | export function loadTopGGAutoPoster() { |
| 116 | if (process.env.TOP_GG_TOKEN) { |