blob: 1edc068a7877bd1e08a8dd97698a2a1ed5155d74 [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) {
TheCodedProf78c13892023-03-05 14:43:06 -05009 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)
76
TheCodedProf920b1c42023-03-05 13:36:57 -050077}