Created
June 22, 2020 18:56
-
-
Save Neztore/462ea7cca219bfa905477e2efc41197f to your computer and use it in GitHub Desktop.
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 characters
| /* | |
| Requires: | |
| - Node-Fetch | |
| - "cookie" variable to be defined | |
| - "groupId" to be set | |
| Generates typescript interfaces from group Audit logs by using typeof to determine the type of response values. | |
| Can only generate interfaces for actions which have occured for a given group before. | |
| */ | |
| const cookie = ""; | |
| const groupId = 0; | |
| const arrayVersion = ["DeletePost", "RemoveMember", "AcceptJoinRequest", "DeclineJoinRequest", | |
| "PostStatus", "ChangeRank", "BuyAd", | |
| "SendAllyRequest", "CreateEnemy", | |
| "AcceptAllyRequest", | |
| "DeclineAllyRequest", "DeleteAlly", "DeleteEnemy", "AddGroupPlace", "RemoveGroupPlace", "CreateItems", "ConfigureItems", "SpendGroupFunds", | |
| "ChangeOwner", "Delete", "AdjustCurrencyAmounts", "Abandon", "Claim", "Rename", "ChangeDescription", "InviteToClan", "KickFromClan", "CancelClanInvite", | |
| "BuyClan", "CreateGroupAsset", "UpdateGroupAsset", "ConfigureGroupAsset", "RevertGroupAsset", "CreateGroupDeveloperProduct", "ConfigureGroupGame", | |
| "Lock", "Unlock", "CreateGamePass", "CreateBadge", "ConfigureBadge", "SavePlace", "PublishPlace" | |
| ]; | |
| async function getlogs (gId, opt: string) { | |
| const res = await fetch(`https://groups.roblox.com/v1/groups/${gId}/audit-log?actionType=${opt}`, { headers: { cookie: `.ROBLOSECURITY=${cookie}` } }); | |
| const resp = await res.json(); | |
| if (resp.errors) { | |
| throw resp.errors[0].message; | |
| } else { | |
| return resp.data[0]; | |
| } | |
| } | |
| for (const item of arrayVersion) { | |
| getlogs(groupId, item) | |
| .then(res => { | |
| if (res) { | |
| const obj = camelify(res.description); | |
| const keys = Object.keys(obj); | |
| // Try to work out what the items are | |
| let outStr = ""; | |
| for (const key of keys) { | |
| outStr = `${outStr}\n${key}: ${typeof obj[key]},`; | |
| } | |
| console.log(`interface ${item}Action { \n${outStr}\n } \n`); | |
| } | |
| }) | |
| .catch(console.error); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment