DEV Community

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

Collapse
 
lioness100 profile image
Lioness100

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!

Collapse
 
elijahtrillionz profile image
Elijah Trillionz • Edited

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

Collapse
 
lioness100 profile image
Lioness100 • Edited

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

developer.mozilla.org/en-US/docs/W...

Thread Thread
 
elijahtrillionz profile image
Elijah Trillionz

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