Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eslym/node-red-discord

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslym/node-red-discord - npm Package Compare versions

Comparing version 0.0.1-alpha.8 to 0.0.1-alpha.9

discord.interaction.update.html

2

discord.builder.component.js
'use strict';
var async = require('./lib/async-12f5d904.js');
var builder = require('./lib/builder-c2c01f3e.js');
var builder = require('./lib/builder-ab248bd6.js');
require('util');

@@ -6,0 +6,0 @@ require('mustache');

'use strict';
var async = require('./lib/async-12f5d904.js');
var builder = require('./lib/builder-c2c01f3e.js');
var builder = require('./lib/builder-ab248bd6.js');
require('util');

@@ -6,0 +6,0 @@ require('mustache');

'use strict';
var async = require('./lib/async-12f5d904.js');
var builder = require('./lib/builder-c2c01f3e.js');
var builder = require('./lib/builder-ab248bd6.js');
require('util');

@@ -6,0 +6,0 @@ require('mustache');

@@ -5,2 +5,3 @@ 'use strict';

var index$1 = require('./lib/index-41639db1.js');
var interaction = require('./lib/interaction-2c1950a9.js');

@@ -27,97 +28,2 @@ function _interopNamespaceDefault(e) {

/**
* @param {import('discord.js').Interaction} interaction
*/
function mapInteraction(interaction) {
let res = {
$instance: () => interaction,
id: interaction.id,
guildId: interaction.guildId,
channelId: interaction.channelId,
message: interaction.message,
member: interaction.member,
user: interaction.user
};
if (interaction.isAnySelectMenu()) {
res.type = 'select';
if (interaction.isUserSelectMenu()) {
res.selectType = 'user';
} else if (interaction.isRoleSelectMenu()) {
res.selectType = 'role';
} else if (interaction.isChannelSelectMenu()) {
res.selectType = 'channel';
} else if (interaction.isMentionableSelectMenu()) {
res.selectType = 'mentionable';
} else if (interaction.isStringSelectMenu()) {
res.selectType = 'string';
}
res.customId = interaction.customId;
res.values = interaction.values;
return res;
}
if (interaction.isButton()) {
res.type = 'button';
res.customId = interaction.customId;
return res;
}
if (interaction.isCommand()) {
res.type = 'command';
res.commandName = interaction.commandName;
res.options = mapCommandOptions(interaction.options.data);
if (interaction.isMessageContextMenuCommand()) {
res.commandType = 'messageContextMenu';
} else if (interaction.isUserContextMenuCommand()) {
res.commandType = 'userContextMenu';
} else if (interaction.isChatInputCommand) {
res.commandType = 'chatInput';
}
return res;
}
if (interaction.isModalSubmit()) {
res.type = 'modal';
res.message = interaction.message;
res.customId = interaction.customId;
res.values = Object.fromEntries(
interaction.fields.fields.map((com) => [com.customId, com.value])
);
return res;
}
return res;
}
/**
*
* @param {import('discord.js').CommandInteractionOption[]} options
*/
function mapCommandOptions(options) {
return Object.fromEntries(
options.map((option) => {
let o = {
name: option.name,
value: option.value,
user: option.user,
channel: option.channel,
role: option.role,
member: option.member,
attachment: option.attachment,
type: [
null,
'subCommand',
'subCommandGroup',
'string',
'integer',
'boolean',
'user',
'channel',
'role',
'mentionable',
'number',
'attachment'
][option.type]
};
return [option.name, o];
})
);
}
/**
* @param {import('node-red').NodeAPI} RED

@@ -165,3 +71,3 @@ */

case 'interactionCreate':
msg.payload = index$1.parse(index$1.stringify(mapInteraction(args[0])));
msg.payload = index$1.parse(index$1.stringify(interaction.mapInteraction(args[0])));
break;

@@ -168,0 +74,0 @@ default:

'use strict';
var interaction = require('./lib/interaction-2c1950a9.js');
var dcjs = require('discord.js');
var index$1 = require('./lib/index-41639db1.js');

@@ -19,9 +21,12 @@ /**

/** @type {import('discord.js').Interaction} */
const interaction = ctx.eventArgs[0];
if(!interaction.isRepliable()) {
const interaction$1 = ctx.eventArgs[0];
if (!interaction$1.isRepliable()) {
throw new Error('Interaction is not repliable');
}
await interaction.deferReply({
ephemeral: config.ephemeral
const reply = await interaction$1.deferReply({
ephemeral: config.ephemeral,
fetchReply: true
});
interaction.getReplies(interaction$1).push(reply);
msg.payload = index$1.parse(index$1.stringify(interaction.mapInteraction(reply)));
send(msg);

@@ -28,0 +33,0 @@ done();

@@ -20,5 +20,10 @@ 'use strict';

const interaction = ctx.eventArgs[0];
if (!interaction.isModalSubmit() && !interaction.isMessageComponent()) {
const updateable =
interaction.isMessageComponent() ||
(interaction.isModalSubmit() && interaction.isFromMessage());
if (!updateable) {
throw new Error('Interaction is not updateable');
}
await interaction.deferUpdate();

@@ -25,0 +30,0 @@ send(msg);

@@ -5,5 +5,6 @@ 'use strict';

var index$1 = require('./lib/index-41639db1.js');
var util = require('util');
var builder = require('./lib/builder-c2c01f3e.js');
var Mustache = require('mustache');
var builder = require('./lib/builder-ab248bd6.js');
var interaction = require('./lib/interaction-2c1950a9.js');
require('util');
require('mustache');

@@ -14,4 +15,2 @@ /**

function index (RED) {
const prop = util.promisify(RED.util.evaluateNodeProperty);
function DiscordInteractionReplyNode(config) {

@@ -27,35 +26,17 @@ RED.nodes.createNode(this, config);

/** @type {import('discord.js').Interaction} */
const interaction = ctx.eventArgs[0];
if (!interaction.isRepliable()) {
const interaction$1 = ctx.eventArgs[0];
if (!interaction$1.isRepliable()) {
throw new Error('Interaction is not repliable');
}
let message;
const opts = await builder.evaluatePropOrMessage(
RED,
this,
msg,
config.messageSrc,
config.message,
config.msg
);
if (config.messageSrc === 'builder') {
message = await builder.evaluateMessage(RED, this, msg, config.msg);
} else {
message = await prop(config.message, config.messageSrc, this, msg);
if (config.messageSrc === 'str') {
message = Mustache.render(message, msg);
}
}
/** @type {import('discord.js').MessageCreateOptions} */
let opts = {};
if (typeof message === 'string') {
opts.content = message;
} else if (typeof message === 'object') {
opts = {
content: message.content,
tts: message.tts,
nonce: message.nonce,
embeds: message.embeds,
components: message.components,
files: message.files
};
}
const result = await interaction.reply({
const result = await interaction$1.reply({
...opts,

@@ -66,4 +47,6 @@ ephemeral: config.ephemeral,

msg.payload = index$1.parse(index$1.stringify(result));
interaction.getReplies(interaction$1).push(result);
msg.payload = index$1.parse(index$1.stringify(interaction.mapInteraction(interaction$1)));
send(msg);

@@ -70,0 +53,0 @@

@@ -5,4 +5,4 @@ 'use strict';

var util = require('util');
var builder = require('./lib/builder-c2c01f3e.js');
var Mustache = require('mustache');
var builder = require('./lib/builder-ab248bd6.js');
require('mustache');
require('discord.js');

@@ -43,13 +43,2 @@

let message;
if (config.messageSrc === 'builder') {
message = await builder.evaluateMessage(RED, this, msg, config.msg);
} else {
message = await prop(config.message, config.messageSrc, this, msg);
if (config.messageSrc === 'str') {
message = Mustache.render(message, msg);
}
}
/** @type {import('discord.js').Client} */

@@ -64,18 +53,11 @@ let client = config.useMsg ? msg.$dc().client : this.clientNode.discordClient;

/** @type {import('discord.js').MessageCreateOptions} */
let opts = {};
let opts = await builder.evaluatePropOrMessage(
RED,
this,
msg,
config.messageSrc,
config.message,
config.msg
);
if (typeof message === 'string') {
opts.content = message;
} else if (typeof message === 'object') {
opts = {
content: message.content,
tts: message.tts,
nonce: message.nonce,
embeds: message.embeds,
components: message.components,
files: message.files
};
}
if (reply !== undefined) {

@@ -82,0 +64,0 @@ opts.reply = {

{
"version": "0.0.1-alpha.8",
"version": "0.0.1-alpha.9",
"description": "discord.js for node-red",

@@ -25,2 +25,3 @@ "type": "commonjs",

"discord.presence.activity": "discord.presence.activity.js",
"discord.interaction.update": "discord.interaction.update.js",
"discord.interaction.reply": "discord.interaction.reply.js",

@@ -27,0 +28,0 @@ "discord.interaction.defer-update": "discord.interaction.defer-update.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc