Last active
December 12, 2022 23:30
-
-
Save tadhgboyle/c33c22b473d69d866a899cecff318d3d to your computer and use it in GitHub Desktop.
Revisions
-
tadhgboyle revised this gist
Dec 12, 2022 . 1 changed file with 13 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,51 +1,46 @@ // usage: `node main.js <full luckperms editor url>` const process = require('process'); const luckPermsEditorUrl = process.argv[2].match(/https:\/\/luckperms.net\/editor\/(.*)/i); if (!luckPermsEditorUrl) { console.log('β Gimme an LP Editor URL!'); process.exit(1); } const code = luckPermsEditorUrl[1]; if (!luckPermsEditorUrl) { console.log('β Unable to find code in URL!'); process.exit(1); } console.log(`π Found valid code (${code})`); console.log('β²οΈ Loading data from API...'); fetch(`https://usercontent.luckperms.net/${code}`) .then(resp => { if (resp.status !== 200) { throw new Error(`${resp.status} ${resp.statusText}`); } console.log('β Loaded data from API'); const users = resp.data.permissionHolders.filter(p => p.type === 'user'); let totalNumberOfUsers = users.length; const numberOfPirates = users.reduce((num, p) => { const uuid = p.id.split('-')[2]; if (!uuid.startsWith('4')) { num++; } return num; }, 0); if (numberOfPirates > 0) { console.log(`π¨ ${numberOfPirates} out of ${totalNumberOfUsers} users are pirates (${ (totalNumberOfUsers/numberOfPirates) * 100 }%)!`); process.exit(1); } -
tadhgboyle revised this gist
Jan 19, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ axios.get(`https://usercontent.luckperms.net/${code}`) users.forEach(p => { const uuid = p.id.split('-')[2]; if (!uuid.startsWith('4')) { numberOfPirates++; } }); -
tadhgboyle revised this gist
Jan 19, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ // usage: `node main.js <full luckperms editor url>` const process = require('process'); const axios = require('axios'); -
tadhgboyle created this gist
Jan 19, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ const process = require('process'); const axios = require('axios'); const luckPermsEditorUrl = process.argv[2]; const shouldAnnoy = process.argv[3] !== 'false'; if (!luckPermsEditorUrl) { console.log('β Gimme an LP Editor URL!'); process.exit(1); } const code = luckPermsEditorUrl.split('/').pop(); if (!luckPermsEditorUrl) { console.log('β Unable to find code in URL!'); process.exit(1); } if (shouldAnnoy) { console.log(`π Found valid code (${code})`); console.log('β²οΈ Loading data from API...'); } axios.get(`https://usercontent.luckperms.net/${code}`) .then(resp => { if (resp.status !== 200) { throw new Error(`${resp.status} ${resp.statusText}`); } if (shouldAnnoy) { console.log('β Loaded data from API'); } const users = resp.data.permissionHolders.filter(p => p.type === 'user'); let numberOfPirates = 0; let totalNumberOfUser = users.length; users.forEach(p => { const uuid = p.id.split('-')[2]; if (uuid.startsWith('3')) { numberOfPirates++; } }); if (numberOfPirates > 0) { console.log(`π¨ ${numberOfPirates} out of ${totalNumberOfUser} users are pirates (${ (totalNumberOfUser/numberOfPirates) * 100 }%)!`); process.exit(1); } console.log('β No piracy detected'); }) .catch(err => { console.log(`β Error loading data from API: ${err.message}`); process.exit(1); });