feat(discord): use bot auth instead of user
This commit is contained in:
@@ -13,6 +13,7 @@ export default async function createAuthData($: IGlobalVariable) {
|
|||||||
client_id: $.auth.data.consumerKey as string,
|
client_id: $.auth.data.consumerKey as string,
|
||||||
redirect_uri: callbackUrl,
|
redirect_uri: callbackUrl,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
|
permissions: '2146958591',
|
||||||
scope: scopes.join(' '),
|
scope: scopes.join(' '),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -39,6 +39,18 @@ export default {
|
|||||||
description: null,
|
description: null,
|
||||||
docUrl: 'https://automatisch.io/docs/discord#consumer-secret',
|
docUrl: 'https://automatisch.io/docs/discord#consumer-secret',
|
||||||
clickToCopy: false
|
clickToCopy: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'botToken',
|
||||||
|
label: 'Bot token',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
readOnly: false,
|
||||||
|
value: null,
|
||||||
|
placeholder: null,
|
||||||
|
description: null,
|
||||||
|
docUrl: 'https://automatisch.io/docs/discord#bot-token',
|
||||||
|
clickToCopy: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
authenticationSteps: [
|
authenticationSteps: [
|
||||||
@@ -62,6 +74,10 @@ export default {
|
|||||||
{
|
{
|
||||||
name: 'consumerSecret',
|
name: 'consumerSecret',
|
||||||
value: '{fields.consumerSecret}'
|
value: '{fields.consumerSecret}'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'botToken',
|
||||||
|
value: '{fields.botToken}'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -154,6 +170,10 @@ export default {
|
|||||||
{
|
{
|
||||||
name: 'consumerSecret',
|
name: 'consumerSecret',
|
||||||
value: '{fields.consumerSecret}'
|
value: '{fields.consumerSecret}'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'botToken',
|
||||||
|
value: '{fields.botToken}'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,10 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
|||||||
expires_in: expiresIn,
|
expires_in: expiresIn,
|
||||||
scope: scope,
|
scope: scope,
|
||||||
token_type: tokenType,
|
token_type: tokenType,
|
||||||
|
guild: {
|
||||||
|
id: guildId,
|
||||||
|
name: guildName,
|
||||||
|
}
|
||||||
} = verifiedCredentials;
|
} = verifiedCredentials;
|
||||||
|
|
||||||
await $.auth.set({
|
await $.auth.set({
|
||||||
@@ -44,6 +48,8 @@ const verifyCredentials = async ($: IGlobalVariable) => {
|
|||||||
userId: user.id,
|
userId: user.id,
|
||||||
screenName: user.username,
|
screenName: user.username,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
|
guildId,
|
||||||
|
guildName,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { TBeforeRequest } from '@automatisch/types';
|
import { TBeforeRequest } from '@automatisch/types';
|
||||||
|
|
||||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||||
const { tokenType, accessToken } = $.auth.data;
|
const { tokenType, botToken } = $.auth.data;
|
||||||
if (tokenType && accessToken) {
|
if (tokenType && botToken) {
|
||||||
requestConfig.headers.Authorization = `${tokenType} ${accessToken}`;
|
requestConfig.headers.Authorization = `Bot ${botToken}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return requestConfig;
|
return requestConfig;
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
const scopes = ['identify', 'email'];
|
const scopes = ['bot', 'identify'];
|
||||||
|
|
||||||
export default scopes;
|
export default scopes;
|
||||||
|
Reference in New Issue
Block a user