blob: 6286465c201fa0ae0c7d61a456415a39833ab687 [file] [log] [blame]
Skyler Grey67691762023-03-06 09:58:19 +00001import * as fs from "fs";
TheCodedProf78c13892023-03-05 14:43:06 -05002import client from "../client.js";
3import _ from "lodash";
TheCodedProf920b1c42023-03-05 13:36:57 -05004
Skyler Grey67691762023-03-06 09:58:19 +00005const dir = "./data";
TheCodedProf920b1c42023-03-05 13:36:57 -05006const files = fs.readdirSync(dir);
7
8for (const file of files) {
TheCodedProf9f012112023-03-05 14:55:41 -05009 // eslint-disable-next-line @typescript-eslint/no-explicit-any
10 let rsmData: any;
TheCodedProf78c13892023-03-05 14:43:06 -050011 try {
Skyler Grey67691762023-03-06 09:58:19 +000012 rsmData = JSON.parse(fs.readFileSync(`${dir}/${file}`, "utf8"));
13 } catch {
14 continue;
15 }
TheCodedProf78c13892023-03-05 14:43:06 -050016 if (!rsmData.version || rsmData.version < 3) continue;
Skyler Grey67691762023-03-06 09:58:19 +000017 const nucleusData = await client.database.guilds.readOld(rsmData.guild_info.id);
TheCodedProf78c13892023-03-05 14:43:06 -050018 const rsmToNucleus = {
19 id: rsmData.guild_info.id,
20 version: 1,
21 singleEventNotifications: {},
22 filters: {
23 images: {
24 NSFW: rsmData.images?.nsfw,
Skyler Grey67691762023-03-06 09:58:19 +000025 size: rsmData.images?.toosmall
TheCodedProf78c13892023-03-05 14:43:06 -050026 },
27 malware: null,
28 wordFilter: {
29 enabled: true,
30 words: {
31 strict: rsmData.wordfilter?.strict,
Skyler Grey67691762023-03-06 09:58:19 +000032 loose: rsmData.wordfilter?.soft
TheCodedProf78c13892023-03-05 14:43:06 -050033 },
34 allowed: {
35 users: rsmData.wordfilter?.ignore?.members,
36 roles: rsmData.wordfilter?.ignore?.roles,
Skyler Grey67691762023-03-06 09:58:19 +000037 channels: rsmData.wordfilter?.ignore?.channels
38 }
TheCodedProf78c13892023-03-05 14:43:06 -050039 },
40 invite: {
41 enabled: rsmData.invite?.enabled,
42 allowed: {
43 channels: rsmData.invite?.whitelist?.members,
44 roles: rsmData.invite?.whitelist?.roles,
Skyler Grey67691762023-03-06 09:58:19 +000045 users: rsmData.invite?.whitelist?.channels
46 }
TheCodedProf78c13892023-03-05 14:43:06 -050047 }
48 },
49 welcome: {
50 enabled: true,
51 role: rsmData.welcome?.role,
52 channel: rsmData.welcome?.message?.channel,
Skyler Grey67691762023-03-06 09:58:19 +000053 message: rsmData.welcome?.message?.text ?? null
TheCodedProf78c13892023-03-05 14:43:06 -050054 },
55 logging: {
56 logs: {
57 enabled: true,
Skyler Grey67691762023-03-06 09:58:19 +000058 channel: rsmData.log_info?.log_channel
TheCodedProf78c13892023-03-05 14:43:06 -050059 },
60 staff: {
Skyler Grey67691762023-03-06 09:58:19 +000061 channel: rsmData.log_info?.staff
TheCodedProf78c13892023-03-05 14:43:06 -050062 }
63 },
64 verify: {
65 enabled: true,
Skyler Grey67691762023-03-06 09:58:19 +000066 role: rsmData.verify_role
TheCodedProf78c13892023-03-05 14:43:06 -050067 },
68 tickets: {
69 enabled: true,
70 category: rsmData.modmail?.cat,
71 supportRole: rsmData.modmail?.mention,
Skyler Grey67691762023-03-06 09:58:19 +000072 maxTickets: rsmData.modmail?.max
TheCodedProf78c13892023-03-05 14:43:06 -050073 },
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)
TheCodedProf48865eb2023-03-05 15:25:25 -050079 await client.database.guilds.write(merged.id!, merged);
TheCodedProf920b1c42023-03-05 13:36:57 -050080}