Member-only story
Part 2:
Let’s finish this once and for all
Welcome to Part 2 of the tutorial. We’re going to be finishing up our bot by adding complex commands! Of course, make sure you have the prerequisites.
Prerequisites
- Node.js and NPM
- A code editor (obviously) — I’ll be using Visual Studio Code from Microsoft
- A Discord and Heroku account
Resuming Step 3: Coding the bot
If you followed Part 1, your code should look like this:
Okay, so now, let’s create some more complex commands. If you’re making a moderation bot, the commands we make will be quite useful.
Let’s say someone on your server keeps deleting their messages. You can create a command on your bot that will alert that user to stop deleting their messages. Let’s create a .on()
function that listens for any messages being deleted. It’s going to listen for "messageDelete"
and will accept the parameter of msg
so we can send messages in the channel.
client.on("messageDelete", msg => {// Code goes here})
Alright, now that we set up our function, we can make it send a message when the user deletes a message. For this, I am going to be using…