UNPKG

n8n-nodes-discord

Version:

nodes to trigger workflows from Discord or send interactive messages. Uses the components API which allows to create dialogs (e.g. attach buttons and wait for the user to click on them)

46 lines 2.36 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); const helpers_1 = require("../helpers"); const state_1 = __importDefault(require("../state")); async function default_1(ipc, client) { ipc.server.on('execution', async (data, socket) => { try { ipc.server.emit(socket, 'execution', true); if (data.executionId && data.channelId) { state_1.default.executionMatching[data.executionId] = Object.assign({ channelId: data.channelId }, (data.userId ? { userId: data.userId } : {})); if (data.placeholderId && data.apiKey && data.baseUrl) { state_1.default.executionMatching[data.executionId].placeholderId = data.placeholderId; const checkExecution = async (placeholderId, executionId, apiKey, baseUrl) => { const headers = { accept: 'application/json', 'X-N8N-API-KEY': apiKey, }; const res = await axios_1.default .get(`${data.baseUrl}/executions/${executionId}`, { headers }) .catch((e) => e); if (res && res.data && res.data.finished === false && res.data.stoppedAt === null) { setTimeout(() => { if (state_1.default.placeholderMatching[placeholderId]) checkExecution(placeholderId, executionId, apiKey, baseUrl); }, 3000); } else { delete state_1.default.placeholderMatching[placeholderId]; delete state_1.default.executionMatching[data.executionId]; } }; checkExecution(data.placeholderId, data.executionId, data.apiKey, data.baseUrl); } } } catch (e) { (0, helpers_1.addLog)(`${e}`, client); } }); } exports.default = default_1; //# sourceMappingURL=execution.ipc.js.map