-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup.js
More file actions
22 lines (17 loc) · 1017 Bytes
/
Copy pathcleanup.js
File metadata and controls
22 lines (17 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/**
This macro will...
- delete all party users and their actors/characters
- clear the party stash
- delete all newly orphaned macros not in folders
**/
const party = game.actors.party.members.filter((c) => c.type === 'character' && !['Animal Companion', 'Eidolon', 'Construct Companion'].includes(c.class?.name));
const otherActors = game.actors.filter((a) => !game.actors.party.members.includes( a ) );
const gm = game.user.isGM ? game.user.id : 'foo';
const users = party.map((a) => game.users.get( Object.entries( a.ownership )
.filter((r) => r[0] !== gm && r[0] !== 'default' && r[1] === 3 )
.map((r) => r[0] )[0] ) )
.filter((u) => !otherActors.find((p) => Object.keys( p.ownership ).includes( u.id ) ) );
for ( const a of game.actors.party.members ) { a.delete() }
for ( const u of users ) { u.delete() }
await game.actors.party.deleteEmbeddedDocuments("Item", [], { deleteAll: true });
await game.macros.filter((m) => !m.hasPlayerOwner && m.folder === null ).forEach((m) => m.delete() );