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)
65 lines • 2.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Discord = void 0;
const node_ipc_1 = __importDefault(require("node-ipc"));
const DiscordSend_node_options_1 = require("./DiscordSend.node.options");
const bot_1 = __importDefault(require("./bot"));
const helpers_1 = require("./bot/helpers");
if (!process.send)
(0, bot_1.default)();
const nodeDescription = {
displayName: 'Discord Send',
name: 'discordSend',
group: ['discord'],
version: 1,
description: 'Send messages, embeds and prompts to Discord',
defaults: {
name: 'Discord Send',
},
icon: 'file:discord.svg',
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'discordApi',
required: true,
},
],
properties: DiscordSend_node_options_1.options,
};
class Discord {
constructor() {
this.description = nodeDescription;
this.methods = {
loadOptions: {
async getChannels() {
return await (0, helpers_1.getChannels)(this);
},
async getRoles() {
return await (0, helpers_1.getRoles)(this);
},
},
};
}
async execute() {
const returnData = [];
const credentials = (await this.getCredentials('discordApi'));
console.log('credentials', credentials);
await (0, helpers_1.connection)(credentials).catch((e) => {
throw new Error(e);
});
const nodeParameters = {};
Object.keys(this.getNode().parameters).forEach((key) => {
nodeParameters[key] = this.getNodeParameter(key, 0, '');
});
if (nodeParameters.channelId && nodeParameters.type) {
node_ipc_1.default.of.bot.emit(`send:${nodeParameters.type}`, nodeParameters);
}
return this.prepareOutputData(returnData);
}
}
exports.Discord = Discord;
//# sourceMappingURL=DiscordSend.node.js.map