n8n-nodes-discord-dnd
Version:
n8n node to create triggers for Discord events
31 lines • 1.62 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiscordActions = void 0;
const client_1 = require("./client");
const DiscordIntentMapping_1 = require("../definitions/DiscordIntentMapping");
const DiscordActionDescription_1 = require("../definitions/node-description/DiscordActionDescription");
const DiscordActionMethods_1 = require("../definitions/node-methods/DiscordActionMethods");
const ActionEventHandler_1 = require("../handlers/action/ActionEventHandler");
class DiscordActions {
constructor() {
this.description = DiscordActionDescription_1.DiscordActionDescription;
this.methods = DiscordActionMethods_1.DiscordActionMethods;
}
async execute() {
const credentials = await this.getCredentials("discordApiDnd");
const parameters = {
actionType: this.getNodeParameter("actionType", 0),
action: this.getNodeParameter("action", 0),
};
const clientOptions = (0, DiscordIntentMapping_1.getclientOptions)(parameters.actionType);
const client = await (0, client_1.initializeDiscordClient)(credentials.botToken, clientOptions);
const eventHandler = new ActionEventHandler_1.ActionEventHandler(client, this);
const result = await eventHandler.setupEventHandler(parameters.action);
// Close the Discord client connection
await client.destroy();
// Return the result data properly formatted for n8n
return [this.helpers.returnJsonArray([result])];
}
}
exports.DiscordActions = DiscordActions;
//# sourceMappingURL=DiscordActions.node.js.map
;