Skip to content

Commit 05d7fc9

Browse files
committed
feat: add instructions to bot create form
1 parent 74fadd8 commit 05d7fc9

File tree

2 files changed

+46
-27
lines changed

2 files changed

+46
-27
lines changed

libs/web/bot/ui/src/lib/user-bot-server-ui-update-form.tsx

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import { ReactNode } from 'react'
77
import { DiscordUiChannelSelect } from './discord-ui-channel-select'
88
import { DiscordUiRoleSelect } from './discord-ui-role-select'
99

10-
export interface GroupedOption {
11-
group: string
12-
data: { value: string; label: string }[]
13-
}
1410
export function UserBotServerUiUpdateForm({
1511
children,
1612
submit,
@@ -40,11 +36,7 @@ export function UserBotServerUiUpdateForm({
4036
})
4137

4238
return (
43-
<form
44-
onSubmit={form.onSubmit((values) => {
45-
return submit(values)
46-
})}
47-
>
39+
<form onSubmit={form.onSubmit((values) => submit(values))}>
4840
<UiStack>
4941
<DiscordUiRoleSelect
5042
label="Admin Role"
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,52 @@
1-
import { Button, Group } from '@mantine/core'
1+
import { Anchor, Button, Group, Text, TextInput } from '@mantine/core'
2+
import { useForm } from '@mantine/form'
23
import { UserCreateBotInput } from '@pubkey-link/sdk'
3-
import { formFieldText, UiForm, UiFormField } from '@pubkey-ui/core'
4+
import { UiInfo, UiStack } from '@pubkey-ui/core'
45

56
export function UserBotUiCreateForm({ submit }: { submit: (res: UserCreateBotInput) => Promise<boolean> }) {
6-
const model: UserCreateBotInput = {
7-
token: '',
8-
clientId: '',
9-
clientSecret: '',
10-
communityId: '',
11-
}
7+
const form = useForm<UserCreateBotInput>({
8+
initialValues: {
9+
clientId: '',
10+
clientSecret: '',
11+
communityId: '',
12+
token: '',
13+
},
14+
})
1215

13-
const fields: UiFormField<UserCreateBotInput>[] = [
14-
formFieldText('token', { label: 'Token', required: true }),
15-
formFieldText('clientId', { label: 'Client ID', required: true }),
16-
formFieldText('clientSecret', { label: 'Client Secret', required: true }),
17-
]
1816
return (
19-
<UiForm model={model} fields={fields} submit={(res) => submit(res as UserCreateBotInput)}>
20-
<Group justify="right">
21-
<Button type="submit">Create</Button>
22-
</Group>
23-
</UiForm>
17+
<form onSubmit={form.onSubmit((values) => submit(values))}>
18+
<UiStack>
19+
<Text span size="lg">
20+
Create an app in the{' '}
21+
<Anchor href="https://discord.com/developers/applications">Discord Developer Portal</Anchor> or use an
22+
existing one.
23+
</Text>
24+
25+
<TextInput
26+
label="Discord Client ID"
27+
description="Copy the CLIENT ID value from the OAuth2 section of your app."
28+
placeholder="123456789987654321"
29+
{...form.getInputProps('clientId')}
30+
/>
31+
<TextInput
32+
label="Discord Client Secret"
33+
description="Copy the CLIENT SECRET value from OAuth2 section of your app."
34+
placeholder="ABCDEFGHIJKL-MNOPQRSTUVWXYZ"
35+
{...form.getInputProps('clientSecret')}
36+
/>
37+
<TextInput
38+
label="Discord Bot Token"
39+
description="Copy the TOKEN value from the Bot section of your app."
40+
placeholder="ABCDEFGHIJKLMNOPQRSTUVWXYZ.12345.ABCDEFGHIJKLMNOPQRSTUVWXYZ"
41+
{...form.getInputProps('token')}
42+
/>
43+
44+
<UiInfo message="Make sure to enable the 'SERVER MEMBERS INTENT' option in the bot settings." />
45+
46+
<Group justify="right">
47+
<Button type="submit">Create</Button>
48+
</Group>
49+
</UiStack>
50+
</form>
2451
)
2552
}

0 commit comments

Comments
 (0)