npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@metafam/node-red-node-discord

v2.3.2

Published

Discord nodes for recieving / sending messages.

Downloads

6

Readme

node-red-node-discord

Inspired by node-red-contrib-discord

Node-red nodes that allow you to interact with Discord, via Discord.js. Can be used to implement simple write/read Bots

Installation

Run the following command in ~/.node-red:

npm install node-red-node-discord

Nodes

node-red-node-discord gives you access to following nodes:

  • discord-get-messages is a node with no inputs and one output allowing you to receive notifications of incoming messages.
  • discord-get-emoji-reactions is a node with no inputs and one output allowing you to receive notifications when user reacts on message with emoji.
  • discord-send-messages is a node with one input and no outputs allowing you to send messages to a Discord channel.
  • discord-members-monitoring is a node with one input and output, designed to get all channels and their's members for metrics.

discord-get-messages

  • Triggers whenever a message was received on Discord
  • You can pass list of channels to listen to Note : valid channel list example #1245#general#1234567#another-channel
  • msg.payload will be set to the textual content of the message
  • msg.channel will be set to an Object containing info on the channel the message was received from (does not contain any discord.js functions)
  • msg.author will be set to an Object containing info on the user that sent the message (does not contain any discord.js functions)
  • msg.attachments will be set to Array containing attachments info in format
{
  filename: string, // Filename
  href: string // File Url generated by Discord
}
  • msg.rawData will be set to an Object containing info on the message that was received, but again without any of the discord.js functions
  • To reply to a message, use the discord-send-messages node.

discord-send-messages

  • Sends msg.payload on Discord channel with id msg.channel You can pass channel name in msg.channel as well as id, i.e. general Note: this feature possibly can cause sending message to wrong channel if bot connected to multiple servers and there are same named channels

  • Feel free to @mention people in message.payload Example: Hello @Gago, nice module :) , also you can use @here, @everyone mentions

  • To use discord's rich text embed specify msg.rich with following content (props marked with ? are not required)

    {
       title?: string;
       description?: string;
       url?: string;
       color?: ColorResolvable;
       timestamp?: number | Date;
       footer?: {
                   icon?: string;
                   text: string;
                 };
       thumbnail?: string;
       author: {
                 name: string;
                 icon?: string;
                 url?: string;
               };
    
       attachments?: Attachment[];
       field?: {
                 name: string;
                 value: string;
                 inline?: boolean;
                 };
       fields?: [
                   {
                     name: string;
                     value: string;
                     inline?: boolean;
                   }
                 ];
    }
  • msg.attachments contains attachments to send, it must be array containing objects in format

    {
       name: string;
       file: string | Buffer | Stream;
    }

    discord-members-monitoring

    • Triggered from outside, for now doesn't provide any configuration options
    • Set's monitored data to msg.monitoringData with following content
    {
    [category: string]: [
    	{
    	id: string;
    	channelName: string;
    	members: [
    		{
    		id: string;
    		username: string;
    		joinedDate: Date;
    		permissions: PermissionString[];
    		roles: [
    			{
     			id: string;
    			name: string;
    			permissions: number;
    			}
    			]
    		}
    		]
    	}
    	]
    }

Troubleshooting

Here is some known issues and workarounds for them

UnhandledPromiseRejectionWarning: TypeError: Cannot assign to read only property 'writeQueueSize' of object '#'

Outgoing node message has a TCP stream which can't be cloned. This needs to be fixed in a future release but for now you can avoid the issue by ensuring the output from the node isn't branched (going to multiple nodes).