Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 1 | import * as fs from "fs"; |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 2 | import client from "../client.js"; |
| 3 | import _ from "lodash"; |
TheCodedProf | 920b1c4 | 2023-03-05 13:36:57 -0500 | [diff] [blame] | 4 | |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 5 | const dir = "./data"; |
TheCodedProf | 920b1c4 | 2023-03-05 13:36:57 -0500 | [diff] [blame] | 6 | const files = fs.readdirSync(dir); |
| 7 | |
| 8 | for (const file of files) { |
TheCodedProf | 9f01211 | 2023-03-05 14:55:41 -0500 | [diff] [blame] | 9 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 10 | let rsmData: any; |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 11 | try { |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 12 | rsmData = JSON.parse(fs.readFileSync(`${dir}/${file}`, "utf8")); |
| 13 | } catch { |
| 14 | continue; |
| 15 | } |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 16 | if (!rsmData.version || rsmData.version < 3) continue; |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 17 | const nucleusData = await client.database.guilds.readOld(rsmData.guild_info.id); |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 18 | const rsmToNucleus = { |
| 19 | id: rsmData.guild_info.id, |
| 20 | version: 1, |
| 21 | singleEventNotifications: {}, |
| 22 | filters: { |
| 23 | images: { |
| 24 | NSFW: rsmData.images?.nsfw, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 25 | size: rsmData.images?.toosmall |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 26 | }, |
| 27 | malware: null, |
| 28 | wordFilter: { |
| 29 | enabled: true, |
| 30 | words: { |
| 31 | strict: rsmData.wordfilter?.strict, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 32 | loose: rsmData.wordfilter?.soft |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 33 | }, |
| 34 | allowed: { |
| 35 | users: rsmData.wordfilter?.ignore?.members, |
| 36 | roles: rsmData.wordfilter?.ignore?.roles, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 37 | channels: rsmData.wordfilter?.ignore?.channels |
| 38 | } |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 39 | }, |
| 40 | invite: { |
| 41 | enabled: rsmData.invite?.enabled, |
| 42 | allowed: { |
| 43 | channels: rsmData.invite?.whitelist?.members, |
| 44 | roles: rsmData.invite?.whitelist?.roles, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 45 | users: rsmData.invite?.whitelist?.channels |
| 46 | } |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 47 | } |
| 48 | }, |
| 49 | welcome: { |
| 50 | enabled: true, |
| 51 | role: rsmData.welcome?.role, |
| 52 | channel: rsmData.welcome?.message?.channel, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 53 | message: rsmData.welcome?.message?.text ?? null |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 54 | }, |
| 55 | logging: { |
| 56 | logs: { |
| 57 | enabled: true, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 58 | channel: rsmData.log_info?.log_channel |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 59 | }, |
| 60 | staff: { |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 61 | channel: rsmData.log_info?.staff |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 62 | } |
| 63 | }, |
| 64 | verify: { |
| 65 | enabled: true, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 66 | role: rsmData.verify_role |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 67 | }, |
| 68 | tickets: { |
| 69 | enabled: true, |
| 70 | category: rsmData.modmail?.cat, |
| 71 | supportRole: rsmData.modmail?.mention, |
Skyler Grey | 6769176 | 2023-03-06 09:58:19 +0000 | [diff] [blame] | 72 | maxTickets: rsmData.modmail?.max |
TheCodedProf | 78c1389 | 2023-03-05 14:43:06 -0500 | [diff] [blame] | 73 | }, |
| 74 | tags: rsmData.tags |
| 75 | } as Partial<ReturnType<typeof client.database.guilds.read>>; |
| 76 | // console.log(rsmToNucleus) |
| 77 | const merged = _.merge(nucleusData, rsmToNucleus); |
| 78 | // console.log(merged) |
TheCodedProf | 48865eb | 2023-03-05 15:25:25 -0500 | [diff] [blame] | 79 | await client.database.guilds.write(merged.id!, merged); |
TheCodedProf | 920b1c4 | 2023-03-05 13:36:57 -0500 | [diff] [blame] | 80 | } |