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 = [
'bot',
'connections',
'email',
'guilds',
'identify',
'messages.read',
'webhook.incoming',
];
@ -44,7 +46,7 @@ export class DiscordOAuth2Api implements ICredentialType {
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden' as NodePropertyTypes,
default: 'permissions=104448',
default: 'permissions=104600',
},
{
displayName: 'Authentication',

View file

@ -544,7 +544,7 @@ export class Discord implements INodeType {
// 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);
} else if (operation === 'get') {
@ -560,17 +560,6 @@ export class Discord implements INodeType {
const endpoint = `/users/${userId}`;
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);
return await this.helpers.requestOAuth2!.call(this, 'discordOAuth2Api', options, oAuth2Options);
} catch (error) {
console.log(error);
// TODO: Prettify error

View file

@ -27,10 +27,6 @@ export const userOperations = [
name: 'Get',
value: 'get',
},
{
name: 'Update Current User',
value: 'updateCurrentUser',
},
],
default: 'getCurrentUser',
description: 'Operation to perform',
@ -39,9 +35,9 @@ export const userOperations = [
export const userFields = [
{
displayName: 'userId',
displayName: 'User ID',
name: 'userId',
description: '',
description: 'ID of the user to retrieve',
type: 'string',
required: true,
default: '',
@ -56,4 +52,4 @@ export const userFields = [
},
},
},
] as INodeProperties[];
] as INodeProperties[];

View file

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