diff --git a/api/src/routes/dash/server.ts b/api/src/routes/dash/server.ts index 89e4c90..5e1e84a 100644 --- a/api/src/routes/dash/server.ts +++ b/api/src/routes/dash/server.ts @@ -16,6 +16,9 @@ type ServerDetails = { serverConfig: any, users: User[], channels: Channel[], + dmOnKick?: boolean, + dmOnWarn?: boolean, + contact?: string, } app.get('/dash/server/:server', requireAuth({ permission: 0 }), async (req: Request, res: Response) => { @@ -118,10 +121,16 @@ app.put('/dash/server/:server/:option', async (req: Request, res: Response) => { type RequestBody = { prefix?: string, spaceAfterPrefix?: boolean, + dmOnKick?: boolean, + dmOnWarn?: boolean, + contact?: boolean, } if (!validateField('prefix', ['string'], 2) || - !validateField('spaceAfterPrefix', ['boolean'], 2) + !validateField('spaceAfterPrefix', ['boolean'], 2) || + !validateField('dmOnKick', ['boolean'], 2) || + !validateField('dmOnWarn', ['boolean'], 2) || + !validateField('contact', ['string'], 2) ) return; const body: RequestBody = req.body; @@ -130,6 +139,9 @@ app.put('/dash/server/:server/:option', async (req: Request, res: Response) => { $set: JSON.parse(JSON.stringify({ // Get rid of undefined fields prefix: body.prefix == '' ? null : body.prefix, spaceAfterPrefix: body.spaceAfterPrefix, + dmOnKick: body.dmOnKick, + dmOnWarn: body.dmOnWarn, + contact: body.contact, })), }); diff --git a/bot/src/bot/modules/api/server_details.ts b/bot/src/bot/modules/api/server_details.ts index 93baac7..297fb8a 100644 --- a/bot/src/bot/modules/api/server_details.ts +++ b/bot/src/bot/modules/api/server_details.ts @@ -19,6 +19,9 @@ type ServerDetails = { serverConfig?: ServerConfig, users: APIUser[], channels: APIChannel[], + dmOnKick?: boolean, + dmOnWarn?: boolean, + contact?: string, } wsEvents.on('req:getUserServerDetails', async (data: ReqData, cb: (data: WSResponse) => void) => { @@ -80,6 +83,9 @@ wsEvents.on('req:getUserServerDetails', async (data: ReqData, cb: (data: WSRespo type: c!.channel_type == 'VoiceChannel' ? 'VOICE' : 'TEXT', icon: c!.generateIconURL(), })), + dmOnKick: serverConfig?.dmOnKick, + dmOnWarn: serverConfig?.dmOnWarn, + contact: serverConfig?.contact, } cb({ success: true, server: response }); diff --git a/web/src/pages/ServerDashboard/ServerDashboard.tsx b/web/src/pages/ServerDashboard/ServerDashboard.tsx index 77b4f58..3a8a6cd 100644 --- a/web/src/pages/ServerDashboard/ServerDashboard.tsx +++ b/web/src/pages/ServerDashboard/ServerDashboard.tsx @@ -29,6 +29,9 @@ type Server = { serverConfig?: { [key: string]: any }, users: User[], channels: Channel[], + dmOnKick?: boolean, + dmOnWarn?: boolean, + contact?: string, } type AntispamRule = { @@ -51,10 +54,19 @@ 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, + dmOnKick?: boolean, + dmOnWarn?: boolean, + contact?: boolean, + }); const [prefix, setPrefix] = useState('' as string|undefined); const [prefixAllowSpace, setPrefixAllowSpace] = useState(false); - + const [dmOnKick, setDmOnKick] = useState(false); + const [dmOnWarn, setDmOnWarn] = useState(false); + const [contact, setContact] = useState(''); + const [botManagers, setBotManagers] = useState([] as string[]); const [moderators, setModerators] = useState([] as string[]); @@ -68,6 +80,9 @@ const ServerDashboard: FunctionComponent = () => { const payload = { ...(changed.prefix ? { prefix } : undefined), ...(changed.prefixAllowSpace ? { spaceAfterPrefix: prefixAllowSpace } : undefined), + ...(changed.dmOnKick ? { dmOnKick } : undefined), + ...(changed.dmOnWarn ? { dmOnWarn } : undefined), + ...(changed.contact ? { contact: contact || null } : undefined), } const res = await axios.put( @@ -91,6 +106,9 @@ const ServerDashboard: FunctionComponent = () => { setPrefix(server.serverConfig?.prefix || ''); setPrefixAllowSpace(!!server.serverConfig?.spaceAfterPrefix); + setDmOnKick(!!server.serverConfig?.dmOnKick); + setDmOnWarn(!!server.serverConfig?.dmOnWarn); + setContact(server.serverConfig?.contact || ''); setBotManagers(server.serverConfig?.botManagers ?? []); setModerators(server.serverConfig?.moderators ?? []); @@ -190,10 +208,6 @@ const ServerDashboard: FunctionComponent = () => { title="Allow space after prefix" description={'Whether the bot recognizes a command if the prefix is followed by a space. Enable if your prefix is a word.'} /> - @@ -231,6 +245,47 @@ const ServerDashboard: FunctionComponent = () => { + + + + <> +

Infraction DMs

+ { setDmOnKick(!dmOnKick); setChanged({ ...changed, dmOnKick: true }) }} + /> + + { setDmOnWarn(!dmOnWarn); setChanged({ ...changed, dmOnWarn: true }) }} + /> + +

Contact info

+

+ Provide a link, email address or instructions for users on how to contact you. + If provided, this data will be sent along with warn/kick/ban DM messages. +

+ { setContact(e.currentTarget.value); setChanged({ ...changed, contact: true }) }} + /> + + + )}