Implement current user operations

This commit is contained in:
Iván Ovejero 2021-03-11 19:30:25 -03:00
parent 5a79894a2f
commit 08e3e2ee37
5 changed files with 9 additions and 21 deletions

View file

@ -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',

View file

@ -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);
} }
} }

View file

@ -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

View file

@ -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[];

View file

@ -1,6 +1,6 @@
export const auditLogEvents = [ export const auditLogEvents = [
{ {
name: 'Bot ADd', name: 'Bot Add',
value: 28, value: 28,
}, },
{ {