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