UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

66 lines 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; exports.execute = execute; const utilities_1 = require("../../../../../utils/utilities"); const utils_1 = require("../../helpers/utils"); const transport_1 = require("../../transport"); const common_description_1 = require("../common.description"); const properties = [ common_description_1.channelRLC, common_description_1.messageIdString, { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add option', default: {}, options: [common_description_1.simplifyBoolean], }, ]; const displayOptions = { show: { resource: ['message'], operation: ['get'], }, hide: { authentication: ['webhook'], }, }; exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties); async function execute(_guildId, userGuilds) { const returnData = []; const items = this.getInputData(); const simplifyResponse = (0, utils_1.createSimplifyFunction)([ 'id', 'channel_id', 'author', 'content', 'timestamp', 'type', ]); const getChannelId = await utils_1.setupChannelGetter.call(this, userGuilds); for (let i = 0; i < items.length; i++) { try { const channelId = await getChannelId(i); const messageId = this.getNodeParameter('messageId', i); let response = await transport_1.discordApiRequest.call(this, 'GET', `/channels/${channelId}/messages/${messageId}`); const simplify = this.getNodeParameter('options.simplify', i, false); if (simplify) { response = simplifyResponse(response); } const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(response), { itemData: { item: i } }); returnData.push(...executionData); } catch (error) { const err = utils_1.parseDiscordError.call(this, error, i); if (this.continueOnFail()) { returnData.push(...utils_1.prepareErrorData.call(this, err, i)); continue; } throw err; } } return returnData; } //# sourceMappingURL=get.operation.js.map