Skip to content

Commit 34c705e

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

File tree

2 files changed

+48
-27
lines changed

2 files changed

+48
-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,54 @@
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 target="_blank" rel="noopener noreferrer" href="https://discord.com/developers/applications">
22+
Discord Developer Portal
23+
</Anchor>{' '}
24+
or use an existing one.
25+
</Text>
26+
27+
<TextInput
28+
label="Discord Client ID"
29+
description="Copy the CLIENT ID value from the OAuth2 section of your app."
30+
placeholder="123456789987654321"
31+
{...form.getInputProps('clientId')}
32+
/>
33+
<TextInput
34+
label="Discord Client Secret"
35+
description="Copy the CLIENT SECRET value from OAuth2 section of your app."
36+
placeholder="ABCDEFGHIJKL-MNOPQRSTUVWXYZ"
37+
{...form.getInputProps('clientSecret')}
38+
/>
39+
<TextInput
40+
label="Discord Bot Token"
41+
description="Copy the TOKEN value from the Bot section of your app."
42+
placeholder="ABCDEFGHIJKLMNOPQRSTUVWXYZ.12345.ABCDEFGHIJKLMNOPQRSTUVWXYZ"
43+
{...form.getInputProps('token')}
44+
/>
45+
46+
<UiInfo message="Make sure to enable the 'SERVER MEMBERS INTENT' option in the bot settings." />
47+
48+
<Group justify="right">
49+
<Button type="submit">Create</Button>
50+
</Group>
51+
</UiStack>
52+
</form>
2453
)
2554
}

0 commit comments

Comments
 (0)