DEV Community

Cover image for I created my first npm package
Erick Ohm
Erick Ohm

Posted on

I created my first npm package

Introduction

My name is Erick, I am a self-taught developer from Mexico, while I mainly do Front-end development, I often make Discord bots for fun, and occasionally get commissions from server owners to make their own custom bot. I'm always open to chatting about Discord bots or web dev stuff so feel free to contact me on Twitter.
Why I made this package:

  • To learn something new.
  • To make my life easier by not having to go back to old projects trying to remember what I did.

create-discordjs-app

What is it?

create-discordjs-app is a simple npm package that automatically generates a discord.js bot template, it includes things like:

  • Command handler
  • Dynamic help command
  • Command Cooldowns
  • Command Permissions
  • ESLint
  • Command Categories

Why not make it a repo?

Mainly 2 reasons:

  • I wanted to automatically install dependencies after generating the files.
  • I wanted to share it with others that might find it useful, and the name is more memorable than a GitHub link.

But like I mentioned earlier, I also wanted to learn something new, and this allowed me to learn how to publish my own npm package, handle versioning more easily, make it automatically download the dependencies needed, and many other things I got to learn from the community's feedback.

Why discord.js?

I am aware of the problems discordjs has and that there are other packages out there that are better optimized for memory use, but I decided to go with discord.js because it's the most popular one out there and the truth is:
Most people are perfectly fine with discord.js, yes I know other libraries might use less memory, and they don't cache anything you don't ask them to and this is great for your bot that needs to be optimized as much as possible because it's in thousands of servers, but most bots out there aren't like that, most bots are in a few servers at a time and these optimizations are not needed.
For beginners or an average user who will have their bot in only a few servers, discord.js is a great option, you can easily find answers to questions, find people that use it, and detailed guides on how to get started.

How can I use it?

If you're interested in using it for your next project you can install the package globally on your machine and use it

npm i create-discordjs-app -g
create-discordjs-app
Enter fullscreen mode Exit fullscreen mode

or you can use it with npx without having to install it globally

npx create-discordjs-app
Enter fullscreen mode Exit fullscreen mode

After that, you will be prompted with a series of questions like your project name, author, license, and bot prefix.
Once the files are generated you can go into the new folder that was created and in the .env file enter your discord token, and then you can start the bot with:

npm start
Enter fullscreen mode Exit fullscreen mode

Downloads in the first week

To my surprise, the npm package was downloaded 300+ times in the first week of being published, thanks to this I got many useful recommendations on how to improve it, things to add, things to remove, and of course the pesky little bugs that went unnoticed during development.
screenshot of weekly downloads shows 357

Plans and how to get involved

My plans for this package are to polish it as much as I can and to add more options that allow customizing the project to fit your needs and be as useful as possible to as many people as possible.
If you're interested in working on or requesting bug fixes, new features, or better code structure, check out the GitHub page:
https://github.com/erickmack/create-discordjs-app
or contact me on Twitter
@Eriickmack

Top comments (3)

Collapse
 
727021 profile image
Andrew Schimelpfening

This looks great. I’ve been thinking about learning to make discord bots just for fun; I’ll have to try this out.

Collapse
 
menaiala profile image
Menai Ala Eddine

It's inspired by create-react-app package, right?

Collapse
 
erickohm profile image
Erick Ohm

Yes, it is!