UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

181 lines 5.75 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 = [ { displayName: 'Name', name: 'name', type: 'string', default: '', required: true, description: 'The name of the channel', placeholder: 'e.g. new-channel', }, { displayName: 'Type', name: 'type', type: 'options', default: '0', required: true, description: 'The type of channel to create', options: [ { name: 'Guild Text', value: '0', }, { name: 'Guild Voice', value: '2', }, { name: 'Guild Category', value: '4', }, ], }, { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add option', default: {}, options: [ { displayName: 'Age-Restricted (NSFW)', name: 'nsfw', type: 'boolean', default: false, description: 'Whether the content of the channel might be nsfw (not safe for work)', displayOptions: { hide: { '/type': ['4'], }, }, }, { displayName: 'Bitrate', name: 'bitrate', type: 'number', default: 8000, placeholder: 'e.g. 8000', typeOptions: { minValue: 8000, maxValue: 96000, }, description: 'The bitrate (in bits) of the voice channel', displayOptions: { show: { '/type': ['2'], }, }, }, { ...common_description_1.categoryRLC, displayOptions: { hide: { '/type': ['4'], }, }, }, { displayName: 'Position', name: 'position', type: 'number', default: 1, }, { displayName: 'Rate Limit Per User', name: 'rate_limit_per_user', type: 'number', default: 0, description: 'Amount of seconds a user has to wait before sending another message', displayOptions: { hide: { '/type': ['4'], }, }, }, { displayName: 'Topic', name: 'topic', type: 'string', default: '', typeOptions: { rows: 2, }, description: 'The channel topic description (0-1024 characters)', placeholder: 'e.g. This channel is about…', displayOptions: { hide: { '/type': ['4'], }, }, }, { displayName: 'User Limit', name: 'user_limit', type: 'number', default: 0, typeOptions: { minValue: 0, maxValue: 99, }, placeholder: 'e.g. 20', description: 'The limit for the number of members that can be in the channel (0 refers to no limit)', displayOptions: { show: { '/type': ['2'], }, }, }, ], }, ]; const displayOptions = { show: { resource: ['channel'], operation: ['create'], }, hide: { authentication: ['webhook'], }, }; exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties); async function execute(guildId) { const returnData = []; const items = this.getInputData(); for (let i = 0; i < items.length; i++) { try { const name = this.getNodeParameter('name', i); const type = this.getNodeParameter('type', i); const options = this.getNodeParameter('options', i); if (options.categoryId) { options.parent_id = options.categoryId.value; delete options.categoryId; } const body = { name, type, ...options, }; const response = await transport_1.discordApiRequest.call(this, 'POST', `/guilds/${guildId}/channels`, body); 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=create.operation.js.map