Guide on how to make a Discord.JS bot in Node-RED

Hi, guys!

A couple of months ago, i tried to use google-fu to find out how to use Discord.JS and node-red together. My Google-fu came short and i did not find any guides with concrete examples. Due to this, i had to experiment on my own.

Im probably not the only one who has been looking for a guide that gets you started, so i figured i would help others in need and made this guide:
https://drusilla.no/2021/05/14/how-to-make-your-own-discord-bot-using-node-red-with-pictures-and-examples/

5 Likes

Nice guide Joe. :clap:

1 Like

Yes, I agree. Nicely written.

1 Like

Thanks, appreciate it! Your guidance on cloning of objects helped a lot, @Steve-Mcl :- ).

You're right, there's an extreme lack of tutorials in that regard. I was quite happy to see it and I can't wait to test it.

These last few days I've been trying the discord-advanced nodes and they're good for receiving messages, but they do not keep the discord API message structure (I wonder why), and couldn't figure out how to do things as basic as replying to a message (including the quote to the original message).

For now, my bot it's just parsing the messages to generate random number sets (to play my own homemade tabletop RPG) but I want to add more functionality, so node-red is able to parse the character sheets in JSON format and keep track of the people's stats during a game.

Step by step.

Thanks for the effort!

Hopefully you'll find it usefull! Using the function-node to handle discordJs is the most versatile option. You can do whatever you want as long as your discordJS version implements it :- ).

The reason why discord-modules does not forward the object through the flow is because it causes node-red to crash if the flow is branched(i touched upon it in the guide).

if you'd like, you could check out my own discord node.
Examples:node-red-contrib-discord-js/EXAMPLES.md at main · Mar10-9us/node-red-contrib-discord-js · GitHub
Node:

I am also in the midst of developing another discord module for more advanced users which is based on the different types of managers, its members and its methods in discordJs. This means that you in a larger degree can reference to the official discordJs documentation. Example of a manager which handles messages:

Not sure when i'll able to release it due to hectic work situation :- )

2 Likes

Sounds really good! :slight_smile:

For now, I managed to do a simple parser to identify a dice rolling command that will produce the results, but I wanted to mention or reply directly to the user that created the command, and with the node I had is impossible. I'll give yours a try, or I'll delve in the tutorial you wrote.

Thanks again!