My journey with Discord bots from Java to Node.js— Part 0 The Setup

Amr Gawish
kblog
2 min readMar 27, 2017

--

Discord is a great chat application for everything gaming, it has amazing communities to discuss different topics with gaming at the heart of it, the whole development echo system has games in its centre.

I started developing a couple of chatbots to help my clan retrieve certain information about Destiny — a FPS game — and multiple communities in my clan started using the chatbot, and I started noticing a lot of quality degradation from the application.

Meanwhile I was hosting another chatbot that uses Node.js and its performance was way better and I’m not going through any of the errors I face using Java, so I decided to switch my code from Java to Node.js, and this series is aiming to be a record of that learning curve and to keep me committed to that project.

Table of Content

Setting it up

The first problem for a windows user like me is to install Node.js, as a windows user that tried to install NodeJS before on Windows and have a lot of conflicts with Node.js, npm and other global modules, I thought about shifting the direction to develop everything using Docker.

I decided to use this article as my reference and get going, and everything went pretty smooth, I just changed a few bits in the Dockerfile to include other libraries like request and Discord.js and also include Node.js version 6 instead of version 4 as Discord.js requires it.

Dockerfile of my Node.js environment (Can change in the future, check it later)

Also notice that I remove the quotes that were surrounding “apt-get…” as they were unnecessary and were causing problems building the image.

To build the image, I’ve ran the command:

docker build -t nodejs-env .

To run the image, simply running:

docker run -it --name nodeservice -p 9000:9000 -v /c/<my_personal_directory>:/usr/src/app nodejs-env /bin/bash

That synchronizes my local folder with the server, and whatever I’m developing locally, will be there at the docker container for me to execute.

Finally I decided to use VisualStudio code because of:

  • Its Node.js support
  • It is a great IDE to use

Conclusion

In this quick post, I just sat up my environment to be able to work with Node.js applications without polluting my windows machine with Node.js and npm.

In the next article I’m going to talk about my decision of structuring my project.

--

--

Editor for

A father, Gamification advocate, and a fellow software craftsman!