Build A Bot (DiscordJS) — A scalable setup with command modules

  • imports
  • setup
  • functions
  • event handlers
  • the call to the load function

Importing to export

Repeat the same process for the “whois” command and then open the new src/commands/index.js file. We need to import all our modules and combine them in one object that we will use in our main bot code.

What was the caveat?

Our ping will now also require the prefix. There would have been multiple possible solutions for this issue but none of them felt clean and as I do not have this bot deployed anywhere yet, I can simply change this right now. ping is now !ping...

  • !dice
  • !dice [1–10]
  • !dice [1–10]d[2, 3, 4, 6, 8, 10, 12, 20, 100]
  • !dice [1–10]d[2, 3, 4, 6, 8, 10, 12, 20, 100] “optional message”

Tracing back our steps

With this we are done with the new command (I know, we skipped the !help part today) but with the new config we made for the last part, we can return once again to the !who command file and make ONE final edit, getting rid of the additional import and instead using the bot param from the execution call.

Some words about me:

If you want to see more of my work and progress, feel free to follow me and check out my other articles. If you clap feverishly for the articles you like most, it will be easier for me to decide which directions to pursue in following articles so use your ability to cast a vote for future content.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Konrad Abe

Konrad Abe

I’m a Web / App Developer & father 👨‍👩‍👧 doing freelance and part-time agency work since 2003, 💻 building stuff on the side 🕹 and attending conferences 🎟