feat(Discord Node): Overhaul (#5351)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
Michael Kret
2023-11-08 16:11:23 +02:00
committed by GitHub
parent afd637b5ea
commit 6a53c2a375
69 changed files with 6688 additions and 271 deletions

View File

@@ -0,0 +1,43 @@
import type {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class DiscordBotApi implements ICredentialType {
name = 'discordBotApi';
displayName = 'Discord Bot API';
documentationUrl = 'discord';
properties: INodeProperties[] = [
{
displayName: 'Bot Token',
name: 'botToken',
type: 'string',
default: '',
required: true,
typeOptions: {
password: true,
},
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bot {{$credentials.botToken}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://discord.com/api/v10/',
url: '/users/@me/guilds',
},
};
}

View File

@@ -0,0 +1,56 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
export class DiscordOAuth2Api implements ICredentialType {
name = 'discordOAuth2Api';
extends = ['oAuth2Api'];
displayName = 'Discord OAuth2 API';
documentationUrl = 'discord';
properties: INodeProperties[] = [
{
displayName: 'Bot Token',
name: 'botToken',
type: 'string',
default: '',
typeOptions: {
password: true,
},
},
{
displayName: 'Grant Type',
name: 'grantType',
type: 'hidden',
default: 'authorizationCode',
},
{
displayName: 'Authorization URL',
name: 'authUrl',
type: 'hidden',
default: 'https://discord.com/api/oauth2/authorize',
required: true,
},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'hidden',
default: 'https://discord.com/api/oauth2/token',
required: true,
},
{
displayName: 'Scope',
name: 'scope',
type: 'hidden',
default: 'identify guilds guilds.join bot',
required: true,
},
{
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden',
default: 'permissions=1642758929655',
},
];
}

View File

@@ -0,0 +1,23 @@
import type { ICredentialType, INodeProperties } from 'n8n-workflow';
export class DiscordWebhookApi implements ICredentialType {
name = 'discordWebhookApi';
displayName = 'Discord Webhook';
documentationUrl = 'discord';
properties: INodeProperties[] = [
{
displayName: 'Webhook URL',
name: 'webhookUri',
type: 'string',
required: true,
default: '',
placeholder: 'https://discord.com/api/webhooks/ID/TOKEN',
typeOptions: {
password: true,
},
},
];
}