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 <michael.k@radency.com>
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
This commit is contained in:
Nihaal Sangha 2024-01-03 09:21:22 +00:00 committed by GitHub
parent 3b6ae2d0a5
commit ef3a57719e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View file

@ -297,7 +297,7 @@ export const simplifyBoolean: INodeProperties = {
// embeds -----------------------------------------------------------------------------------------
const embedFields: INodeProperties[] = [
{
displayName: 'Description (Required)',
displayName: 'Description',
name: 'description',
type: 'string',
default: '',

View file

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

View file

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