mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +00:00
feat: add access control
This commit is contained in:
parent
9c07ff0e54
commit
3f45153b66
47 changed files with 1084 additions and 164 deletions
|
@ -97,6 +97,23 @@ const changeHandlers: Record<keyof GuildDataUpdate, ChangeHandler> = {
|
|||
title: `Categories were changed...`,
|
||||
},
|
||||
],
|
||||
accessControl: (oldValue, newValue) => [
|
||||
{
|
||||
timestamp: new Date().toISOString(),
|
||||
color: 0xab9b9a,
|
||||
fields: [
|
||||
{
|
||||
name: 'Changed Access Control',
|
||||
value: getChangedAccessControl(
|
||||
oldValue as GuildDataUpdate['accessControl'],
|
||||
newValue as GuildDataUpdate['accessControl']
|
||||
).join('\n'),
|
||||
inline: false,
|
||||
},
|
||||
],
|
||||
title: `Access Control was changed...`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const sendAuditLog = async (
|
||||
|
@ -224,3 +241,26 @@ const getChangedCategories = (oldCategories: Category[], newCategories: Category
|
|||
...changedCategories.map((c) => `🔧 **Changed** ${c.name}`),
|
||||
];
|
||||
};
|
||||
|
||||
const getChangedAccessControl = (
|
||||
oldAccessControl: GuildDataUpdate['accessControl'],
|
||||
newAccessControl: GuildDataUpdate['accessControl']
|
||||
) => {
|
||||
const pendingChanged = newAccessControl.blockPending !== oldAccessControl.blockPending;
|
||||
|
||||
return [
|
||||
`✅ Allowed roles: ${
|
||||
newAccessControl.allowList.map((role) => `<@&${role}>`).join(', ') || `*all roles*`
|
||||
}`,
|
||||
`❌ Blocked roles: ${
|
||||
newAccessControl.blockList.map((role) => `<@&${role}>`).join(', ') || `*no roles*`
|
||||
}`,
|
||||
...(pendingChanged
|
||||
? [
|
||||
`🔧 Pending/Welcome Screening users are ${
|
||||
newAccessControl.blockPending ? 'blocked ❌' : 'allowed ✔'
|
||||
}`,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue