mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
⚡ Implement current user operations
This commit is contained in:
parent
5a79894a2f
commit
08e3e2ee37
|
@ -6,8 +6,10 @@ import {
|
||||||
const scopes = [
|
const scopes = [
|
||||||
'bot',
|
'bot',
|
||||||
'connections',
|
'connections',
|
||||||
|
'email',
|
||||||
'guilds',
|
'guilds',
|
||||||
'identify',
|
'identify',
|
||||||
|
'messages.read',
|
||||||
'webhook.incoming',
|
'webhook.incoming',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -44,7 +46,7 @@ export class DiscordOAuth2Api implements ICredentialType {
|
||||||
displayName: 'Auth URI Query Parameters',
|
displayName: 'Auth URI Query Parameters',
|
||||||
name: 'authQueryParameters',
|
name: 'authQueryParameters',
|
||||||
type: 'hidden' as NodePropertyTypes,
|
type: 'hidden' as NodePropertyTypes,
|
||||||
default: 'permissions=104448',
|
default: 'permissions=104600',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Authentication',
|
displayName: 'Authentication',
|
||||||
|
|
|
@ -544,7 +544,7 @@ export class Discord implements INodeType {
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/user#get-current-user-guilds
|
// https://discord.com/developers/docs/resources/user#get-current-user-guilds
|
||||||
|
|
||||||
const endpoint = '/users/@me@guilds';
|
const endpoint = '/users/@me/guilds';
|
||||||
responseData = await discordApiRequest.call(this, 'GET', endpoint);
|
responseData = await discordApiRequest.call(this, 'GET', endpoint);
|
||||||
|
|
||||||
} else if (operation === 'get') {
|
} else if (operation === 'get') {
|
||||||
|
@ -560,17 +560,6 @@ export class Discord implements INodeType {
|
||||||
const endpoint = `/users/${userId}`;
|
const endpoint = `/users/${userId}`;
|
||||||
responseData = await discordApiRequest.call(this, 'GET', endpoint);
|
responseData = await discordApiRequest.call(this, 'GET', endpoint);
|
||||||
|
|
||||||
} else if (operation === 'updateCurrentUser') {
|
|
||||||
|
|
||||||
// ----------------------------------------
|
|
||||||
// user: updateCurrentUser
|
|
||||||
// ----------------------------------------
|
|
||||||
|
|
||||||
// https://discord.com/developers/docs/resources/user#modify-current-user
|
|
||||||
|
|
||||||
const endpoint = '/users/@me';
|
|
||||||
responseData = await discordApiRequest.call(this, 'PATCH', endpoint);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ export async function discordApiRequest(
|
||||||
console.log(options);
|
console.log(options);
|
||||||
return await this.helpers.requestOAuth2!.call(this, 'discordOAuth2Api', options, oAuth2Options);
|
return await this.helpers.requestOAuth2!.call(this, 'discordOAuth2Api', options, oAuth2Options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
// TODO: Prettify error
|
// TODO: Prettify error
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,6 @@ export const userOperations = [
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Update Current User',
|
|
||||||
value: 'updateCurrentUser',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
default: 'getCurrentUser',
|
default: 'getCurrentUser',
|
||||||
description: 'Operation to perform',
|
description: 'Operation to perform',
|
||||||
|
@ -39,9 +35,9 @@ export const userOperations = [
|
||||||
|
|
||||||
export const userFields = [
|
export const userFields = [
|
||||||
{
|
{
|
||||||
displayName: 'userId',
|
displayName: 'User ID',
|
||||||
name: 'userId',
|
name: 'userId',
|
||||||
description: '',
|
description: 'ID of the user to retrieve',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -56,4 +52,4 @@ export const userFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export const auditLogEvents = [
|
export const auditLogEvents = [
|
||||||
{
|
{
|
||||||
name: 'Bot ADd',
|
name: 'Bot Add',
|
||||||
value: 28,
|
value: 28,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue