mirror of
https://github.com/janderedev/automod.git
synced 2024-12-22 10:45:27 +00:00
temp commit
This commit is contained in:
parent
41630149b3
commit
359226229d
|
@ -100,6 +100,27 @@ app.put('/dash/server/:server/:option', async (req: Request, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
case 'votekickTrusted': {
|
||||
if (!item || typeof item != 'string') return badRequest(res);
|
||||
if (permissionLevel < 1) return res.status(403).send({ error: 'You are not allowed to mark roles as trusted.' });
|
||||
|
||||
const serverRes = await botReq('getUserServerDetails', { user: user, server: server });
|
||||
if (!serverRes.success) {
|
||||
return res.status(serverRes.statusCode ?? 500).send({ error: serverRes.error });
|
||||
}
|
||||
|
||||
if (!serverRes.roles.find((r: any) => r.id == item)) {
|
||||
return res.status(404).send({ error: 'The specified role does not appear to exist' });
|
||||
}
|
||||
|
||||
const newRoles = [ ...(settings.votekick.trustedRoles ?? []), item.toUpperCase() ];
|
||||
await servers.update({ id: server }, { $set: { 'votekick.trustedRoles': newRoles } });
|
||||
res.send({
|
||||
success: true,
|
||||
roles: newRoles,
|
||||
});
|
||||
}
|
||||
|
||||
case 'config': {
|
||||
function validateField(field: string, type: string[], level: 0|1|2|3): boolean {
|
||||
if (permissionLevel < level) {
|
||||
|
|
|
@ -19,6 +19,16 @@ type ServerDetails = {
|
|||
serverConfig?: ServerConfig,
|
||||
users: APIUser[],
|
||||
channels: APIChannel[],
|
||||
roles: {
|
||||
id: string,
|
||||
name: string,
|
||||
color?: string,
|
||||
rank?: number,
|
||||
perms: {
|
||||
server: number,
|
||||
channel: number,
|
||||
}
|
||||
}[],
|
||||
}
|
||||
|
||||
wsEvents.on('req:getUserServerDetails', async (data: ReqData, cb: (data: WSResponse) => void) => {
|
||||
|
@ -80,6 +90,18 @@ wsEvents.on('req:getUserServerDetails', async (data: ReqData, cb: (data: WSRespo
|
|||
type: c!.channel_type == 'VoiceChannel' ? 'VOICE' : 'TEXT',
|
||||
icon: c!.generateIconURL(),
|
||||
})),
|
||||
roles: server.roles
|
||||
? Object.entries(server.roles).map(r => ({
|
||||
id: r[0],
|
||||
name: r[1].name,
|
||||
color: r[1].colour,
|
||||
rank: r[1].rank,
|
||||
perms: {
|
||||
server: r[1].permissions[0],
|
||||
channel: r[1].permissions[1],
|
||||
},
|
||||
}))
|
||||
: [],
|
||||
}
|
||||
|
||||
cb({ success: true, server: response });
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.fgtext {
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
|
|
@ -46,9 +46,18 @@ const ServerDashboard: FunctionComponent = () => {
|
|||
const [serverInfo, setServerInfo] = useState({} as Server);
|
||||
const [status, setStatus] = useState('');
|
||||
|
||||
const [changed, setChanged] = useState({} as { prefix?: boolean, prefixAllowSpace?: boolean });
|
||||
const [changed, setChanged] = useState({} as {
|
||||
prefix?: boolean,
|
||||
prefixAllowSpace?: boolean,
|
||||
votekickEnabled?: boolean,
|
||||
votekickRequired?: number,
|
||||
votekickDuration?: number,
|
||||
});
|
||||
const [prefix, setPrefix] = useState('' as string|undefined);
|
||||
const [prefixAllowSpace, setPrefixAllowSpace] = useState(false);
|
||||
const [votekickEnabled, setVotekickEnabled] = useState(false);
|
||||
const [votekickRequired, setVotekickRequired] = useState(0);
|
||||
const [votekickDuration, setVotekickDuration] = useState(0);
|
||||
|
||||
const [botManagers, setBotManagers] = useState([] as string[]);
|
||||
const [moderators, setModerators] = useState([] as string[]);
|
||||
|
@ -86,6 +95,9 @@ const ServerDashboard: FunctionComponent = () => {
|
|||
|
||||
setPrefix(server.serverConfig?.prefix || '');
|
||||
setPrefixAllowSpace(!!server.serverConfig?.spaceAfterPrefix);
|
||||
setVotekickEnabled(!!server.serverConfig?.votekick?.enabled);
|
||||
setVotekickRequired(server.serverConfig?.votekick?.votesRequired ?? 0);
|
||||
setVotekickDuration(server.serverConfig?.votekick?.banDuration ?? 0);
|
||||
|
||||
setBotManagers(server.serverConfig?.botManagers ?? []);
|
||||
setModerators(server.serverConfig?.moderators ?? []);
|
||||
|
@ -160,7 +172,7 @@ const ServerDashboard: FunctionComponent = () => {
|
|||
/>
|
||||
|
||||
<div hidden={Object.keys(serverInfo).length == 0}>
|
||||
<div style={{ paddingLeft: '10px', paddingRight: '10px' }}>
|
||||
<div style={{ paddingLeft: '10px', paddingRight: '10px', paddingBottom: '20px' }}>
|
||||
|
||||
{category == 'home' && (
|
||||
<>
|
||||
|
@ -226,6 +238,67 @@ const ServerDashboard: FunctionComponent = () => {
|
|||
</UserListContainer>
|
||||
</UserListTypeContainer>
|
||||
</>
|
||||
|
||||
<LineDivider />
|
||||
<H3>Votekick</H3>
|
||||
<H4>
|
||||
Votekick allows trusted members to temporarily remove members
|
||||
while no moderator is online.
|
||||
</H4>
|
||||
|
||||
<Checkbox
|
||||
value={votekickEnabled}
|
||||
onChange={() => {
|
||||
setVotekickEnabled(!votekickEnabled);
|
||||
setChanged({ ...changed, votekickEnabled: true });
|
||||
}}
|
||||
title="Enabled"
|
||||
description="Whether users are allowed to votekick"
|
||||
style={{ marginBottom: '12px' }}
|
||||
/>
|
||||
|
||||
<H3>Votes required</H3>
|
||||
<H4>How many trusted members need to vote in order for the user to be removed.</H4>
|
||||
<InputBox
|
||||
style={{
|
||||
width: '150px',
|
||||
margin: '16px 0 0 0',
|
||||
}}
|
||||
onChange={e => {
|
||||
if (e.currentTarget.value != '' && !isNaN(Number(e.currentTarget.value))) {
|
||||
if (Number(e.currentTarget.value) < 0) return;
|
||||
setVotekickRequired(Number(e.currentTarget.value));
|
||||
setChanged({ ...changed, votekickRequired: Number(e.currentTarget.value) })
|
||||
}
|
||||
}}
|
||||
placeholder='3'
|
||||
value={votekickRequired}
|
||||
/>
|
||||
|
||||
<H3>Ban duration</H3>
|
||||
<H4>How long the user will be banned for. Set to 0 for permanent or -1 to kick the user without banning.</H4>
|
||||
<InputBox
|
||||
style={{
|
||||
width: '150px',
|
||||
margin: '16px 0 0 0',
|
||||
}}
|
||||
onChange={e => {
|
||||
if (e.currentTarget.value == '-') e.currentTarget.value = '-1';
|
||||
if (e.currentTarget.value != '' && !isNaN(Number(e.currentTarget.value))) {
|
||||
if (Number(e.currentTarget.value) < -1) return;
|
||||
setVotekickDuration(Number(e.currentTarget.value));
|
||||
setChanged({ ...changed, votekickDuration: Number(e.currentTarget.value) })
|
||||
}
|
||||
}}
|
||||
placeholder='3'
|
||||
value={votekickDuration}
|
||||
/>
|
||||
|
||||
<UserListTypeContainer>
|
||||
<UserListContainer disabled={!serverInfo.perms} >
|
||||
<InputBox />
|
||||
</UserListContainer>
|
||||
</UserListTypeContainer>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
@ -392,10 +465,10 @@ const ServerDashboard: FunctionComponent = () => {
|
|||
);
|
||||
}
|
||||
|
||||
function UserListAddField(props: { type: 'MANAGER'|'MOD' }) {
|
||||
function UserListAddField(props: { type: 'MANAGER'|'MOD'|'TRUSTED' }) {
|
||||
const [content, setContent] = useState('');
|
||||
|
||||
const onConfirm = useCallback(async () => {0
|
||||
const onConfirm = useCallback(async () => {
|
||||
if (content.length) {
|
||||
const res = await axios.put(
|
||||
`${API_URL}/dash/server/${serverid}/${props.type == 'MANAGER' ? 'managers' : 'mods'}`,
|
||||
|
|
Loading…
Reference in a new issue