-
Notifications
You must be signed in to change notification settings - Fork 0
/
restructurize.ts
42 lines (34 loc) · 1.4 KB
/
restructurize.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// move stuff
// deno run --allow-read --allow-write restructurize.ts
for await (const entry of Deno.readDir('.')) {
const fn = entry.name;
if (fn.endsWith('.json')) {
if (fn === 'contributors.json') continue;
console.log('Processing', fn);
const text = await Deno.readTextFile(fn);
const data = JSON.parse(text);
// [2022-04-21] Combine server / channel permissions.
if (data?.permissions?.server) {
Object.keys(data.permissions.server)
.forEach(key => data.permissions[key] = data.permissions.server[key]);
}
if (data?.permissions?.channel) {
Object.keys(data.permissions.channel)
.forEach(key => data.permissions[key] = data.permissions.channel[key]);
}
delete data?.permissions?.server;
delete data?.permissions?.channel;
// [2022-04-21] Move ManageRoles to ManageRole
if (data?.permissions?.ManageRoles) {
data.permissions.ManageRole = data?.permissions?.ManageRoles;
delete data?.permissions?.ManageRoles;
}
// [2022-04-21] Move View to ViewChannel
if (data?.permissions?.View) {
data.permissions.ViewChannel = data?.permissions?.View;
delete data?.permissions?.View;
}
// * Commit
await Deno.writeTextFile(fn, JSON.stringify(data, undefined, '\t'));
}
}