DEV Community

Discussion on: Build A Modern Discord Bot from Scratch. Learn the basics

lioness100 profile image

Very well written! Thanks for this great article. A few notes, though:

Intents are new, but they state the permissions your bot requires.

This isn't true. Intents allow you to subscribe to only the events you want to receive from the discord API to decrease memory usage. Also, why did you include the typing and reaction intents? It didn't seem like those were used in the guide code (and would in fact inflate memory usage unneededly).

if (!msg.content.includes(prefix)) return;

Especially since you're assuming the prefix is at the beginning when you slice it off of the message, you should probably use startsWith, not includes. For example, this would currently pass the "it's a command" check: sad is what I am!

elijahtrillionz profile image
Elijah Trillionz Author • Edited on

Oh thanks for this. I never really understood the intents yet. Will check more on it and make the changes.

Also the intents I stated were originally to be used, but the article had grown to large already.

And thanks for the correction on the prefix. I checked the message properties, but that of content doesn't seem to have any prop (from the docs). Or is it msg.startsWith?, because i still can't find that.

Update: I just verified the startsWith method on VSCode, but I still can't find it in the docs though. It's like it's hidden or something

lioness100 profile image
Lioness100 • Edited on

message.content is a string. You can use any string method on it. It wouldn't be listed on discord.js docs

Thread Thread
elijahtrillionz profile image
Elijah Trillionz Author

oh wow! I didn't know about this method before. Thanks for sharing