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