mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-13 11:53:42 +08:00
feat: support Discord Guild Join
This commit is contained in:
@@ -59,7 +59,7 @@ const LoginForm = () => {
|
||||
|
||||
const onDiscordOAuthClicked = () => {
|
||||
window.open(
|
||||
`https://discord.com/oauth2/authorize?response_type=code&client_id=${status.discord_client_id}&redirect_uri=${window.location.origin}/oauth/discord&scope=identify`,
|
||||
`https://discord.com/oauth2/authorize?response_type=code&client_id=${status.discord_client_id}&redirect_uri=${window.location.origin}/oauth/discord&scope=identify%20guilds%20email%20guilds.join`,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ const SystemSetting = () => {
|
||||
GitHubClientId: '',
|
||||
GitHubClientSecret: '',
|
||||
DiscordClientId: '',
|
||||
DiscordAllowJoiningGuild: 'false',
|
||||
DiscordGuildId: '',
|
||||
DiscordBotToken: '',
|
||||
DiscordClientSecret: '',
|
||||
Notice: '',
|
||||
SMTPServer: '',
|
||||
@@ -87,6 +90,9 @@ const SystemSetting = () => {
|
||||
name.startsWith('SMTP') ||
|
||||
name === 'ServerAddress' ||
|
||||
name === 'DiscordClientId' ||
|
||||
name === 'DiscordGuildId' ||
|
||||
name === 'DiscordAllowJoiningGuild' ||
|
||||
name === 'DiscordBotToken' ||
|
||||
name === 'DiscordClientSecret' ||
|
||||
name === 'GitHubClientId' ||
|
||||
name === 'GitHubClientSecret' ||
|
||||
@@ -177,6 +183,24 @@ const SystemSetting = () => {
|
||||
) {
|
||||
await updateOption('DiscordClientSecret', inputs.DiscordClientSecret);
|
||||
}
|
||||
if (originInputs['DiscordGuildId'] !== inputs.DiscordGuildId) {
|
||||
await updateOption('DiscordGuildId', inputs.DiscordGuildId);
|
||||
}
|
||||
if (
|
||||
originInputs['DiscordBotToken'] !== inputs.DiscordBotToken &&
|
||||
inputs.DiscordBotToken !== ''
|
||||
) {
|
||||
await updateOption('DiscordBotToken', inputs.DiscordBotToken);
|
||||
}
|
||||
if (
|
||||
originInputs['DiscordAllowJoiningGuild'] !==
|
||||
inputs.DiscordAllowJoiningGuild
|
||||
) {
|
||||
await updateOption(
|
||||
'DiscordAllowJoiningGuild',
|
||||
inputs.DiscordAllowJoiningGuild,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const submitTurnstile = async () => {
|
||||
@@ -352,6 +376,32 @@ const SystemSetting = () => {
|
||||
value={inputs.DiscordClientSecret}
|
||||
placeholder='Sensitive information will not be displayed in the frontend'
|
||||
/>
|
||||
<Form.Checkbox
|
||||
label='Allow Joining Guild'
|
||||
name='DiscordAllowJoiningGuild'
|
||||
autoComplete='new-password'
|
||||
checked={inputs.DiscordAllowJoiningGuild === 'true'}
|
||||
onChange={(e, { name, checked }) =>
|
||||
handleInputChange(e, { name, value: checked ? 'true' : 'false' })
|
||||
}
|
||||
/>
|
||||
<Form.Input
|
||||
label='Discord Guild ID'
|
||||
name='DiscordGuildId'
|
||||
onChange={handleInputChange}
|
||||
autoComplete='new-password'
|
||||
value={inputs.DiscordGuildId}
|
||||
placeholder='Enter the ID of your Discord server'
|
||||
/>
|
||||
<Form.Input
|
||||
label='Discord Bot Token'
|
||||
name='DiscordBotToken'
|
||||
onChange={handleInputChange}
|
||||
type='password'
|
||||
autoComplete='new-password'
|
||||
value={inputs.DiscordBotToken}
|
||||
placeholder='Sensitive information will not be displayed in the frontend'
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Button onClick={submitDiscordOAuth}>
|
||||
Save Discord OAuth Settings
|
||||
|
||||
Reference in New Issue
Block a user