fix(Discord Node): Fix wrong error message being displayed (#5547)

This commit is contained in:
Jan Oberhauser 2023-02-22 15:54:52 +01:00 committed by GitHub
parent 0fbb3f0f02
commit e251439333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -133,16 +133,16 @@ export class Discord implements INodeType {
try {
//@ts-expect-error
body.embeds = JSON.parse(options.embeds);
if (!Array.isArray(body.embeds)) {
throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.', {
itemIndex: i,
});
}
} catch (e) {
throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.', {
itemIndex: i,
});
}
if (!Array.isArray(body.embeds)) {
throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.', {
itemIndex: i,
});
}
}
if (options.username) {
body.username = options.username as string;