From ef3a57719eb42777502cafdd38009e6cb5b484ce Mon Sep 17 00:00:00 2001 From: Nihaal Sangha Date: Wed, 3 Jan 2024 09:21:22 +0000 Subject: [PATCH] fix(Discord Node): Remove unnecessary requirement on parameters (#8060) ## Summary The PR removes the requirement on 2 fields: the `content` and the `description` of embeds. Discord requires neither of these fields and as they weren't required in the v1 node, it prevents migrating to the v2 node for users not providing one of them. Discord does require *something* to be sent however, whether an attachment, an embed or content, so this could be used instead if necessary. ## Review / Merge checklist - [x] PR title and summary are descriptive. **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** ([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md)) - [x] ~~[Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created.~~ (v2 is not documented) - [x] ~~Tests included.~~ (If more complex requirements are set then a test should be added although I haven't worked with n8n's tests before) --------- Co-authored-by: Michael Kret Co-authored-by: Jonathan Bennetts --- .../nodes/Discord/v2/actions/common.description.ts | 2 +- .../Discord/v2/actions/message/send.operation.ts | 1 - .../nodes-base/nodes/Discord/v2/helpers/utils.ts | 12 +++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/nodes-base/nodes/Discord/v2/actions/common.description.ts b/packages/nodes-base/nodes/Discord/v2/actions/common.description.ts index fd3ae41d5f2b3..a4ce3f4147f76 100644 --- a/packages/nodes-base/nodes/Discord/v2/actions/common.description.ts +++ b/packages/nodes-base/nodes/Discord/v2/actions/common.description.ts @@ -297,7 +297,7 @@ export const simplifyBoolean: INodeProperties = { // embeds ----------------------------------------------------------------------------------------- const embedFields: INodeProperties[] = [ { - displayName: 'Description (Required)', + displayName: 'Description', name: 'description', type: 'string', default: '', diff --git a/packages/nodes-base/nodes/Discord/v2/actions/message/send.operation.ts b/packages/nodes-base/nodes/Discord/v2/actions/message/send.operation.ts index e3d9362747872..eb207c53b1ff3 100644 --- a/packages/nodes-base/nodes/Discord/v2/actions/message/send.operation.ts +++ b/packages/nodes-base/nodes/Discord/v2/actions/message/send.operation.ts @@ -63,7 +63,6 @@ const properties: INodeProperties[] = [ name: 'content', type: 'string', default: '', - required: true, description: 'The content of the message (up to 2000 characters)', placeholder: 'e.g. My message', typeOptions: { diff --git a/packages/nodes-base/nodes/Discord/v2/helpers/utils.ts b/packages/nodes-base/nodes/Discord/v2/helpers/utils.ts index 6b3355b3a54c6..8951320a3f757 100644 --- a/packages/nodes-base/nodes/Discord/v2/helpers/utils.ts +++ b/packages/nodes-base/nodes/Discord/v2/helpers/utils.ts @@ -71,6 +71,11 @@ export function parseDiscordError(this: IExecuteFunctions, error: any, itemIndex return new NodeOperationError(this.getNode(), errorData.errors, errorOptions); } + + if (errorOptions.message === 'Cannot send an empty message') { + errorOptions.description = + 'Something has to be send to the channel whether it is a message, an embed or a file'; + } } return new NodeOperationError(this.getNode(), errorData || error, errorOptions); } @@ -133,13 +138,6 @@ export function prepareEmbeds(this: IExecuteFunctions, embeds: IDataObject[], i } } - if (!embedReturnData.description) { - throw new NodeOperationError( - this.getNode(), - `Description is required, embed ${index} in item ${i} is missing it`, - ); - } - if (embedReturnData.author) { embedReturnData.author = { name: embedReturnData.author,