Skip to content

Commit

Permalink
fix(Discord Node): Remove unnecessary requirement on parameters (n8n-…
Browse files Browse the repository at this point in the history
…io#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 <michael.k@radency.com>
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent 3b6ae2d commit ef3a577
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export const simplifyBoolean: INodeProperties = {
// embeds -----------------------------------------------------------------------------------------
const embedFields: INodeProperties[] = [
{
displayName: 'Description (Required)',
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
12 changes: 5 additions & 7 deletions packages/nodes-base/nodes/Discord/v2/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ef3a577

Please sign in to comment.