How to make a Discord Bot for Beginners (Discord.js v14)
Вставка
- Опубліковано 14 жов 2024
- How to make a Discord Bot for Beginners (Discord.js v14)
🌐 Important links:
Discord Developer Portal: / discord
Discord.js official website: discord.js.org
Discord Intents List: discord.com/de...
Patreon: / underctrl
Buy me a coffee (one-time donation): buymeacoffee.c...
🎵 Music Credits:
Track Name: "Blue Boi"
Music By: LAKEY INSPIRED @ / lakeyinspired
Original upload HERE - • LAKEY INSPIRED - Blue Boi
Official "LAKEY INSPIRED" UA-cam Channel HERE - / @lakeyinspired
License for commercial use: Creative Commons Attribution 3.0 Unported "Share Alike" (CC BY-SA 3.0) License.
Full License HERE - creativecommon...
Music promoted by NCM / @chillcopyrightfreemusic
Want me to make you a custom bot? Email me at: avraj@underctrl.io or DM me on Discord: avrajs (PAID WORK)
Source code: github.com/notunderctrl/discordjs-v14-series
Discord server: discord.gg/T4faJeH84A
the insane amount of times i have hear scammers say that and in reality they nuke your server
@@Cyoclonic Thanks for bringing up this concern - I'll help clear it up.
My reputation matters to me. I've been working with clients for web development for over a year at this point.
To make things clear:
1. My clients are paying for the code I write. They own it at the end of the day and have full authority to check and see what's going on with the code.
2. If I'm doing bot development, I do the bot development in a separate guild so as to not disturb the flow of my client's community.
3. In most situations (considering the project scale), we work with a legal contract to protect the interest of both parties.
@@UnderCtrl Jesus Christ I didn't expect an entire essay dude I was just joking 😭 but can you make a vid on how to fix nodeom thingy it keeps saying that security is not letting me.do it
@@Cyoclonic got an faq in our Discord about the powershell security policy: underctrl.io/discord
I did the tutorial and my bot isnt turnin on
10/10 tutorial guys literally spent the whole afternoon checking out tutorials and this one is the only one that worked because of the V14 update. You deserve way more views 🙌
Fr
WOW just WOW. This is unbelievable that I literally set up my first discord bot successfully like literally just following along. I cant thank you enough. The way you explained every detail in depth and in such beginner friendly way was just awesome. Thank you so much!!
Thank you for this, I’m a complete newbie to discord bot.. and programming as a whole. I had been following guides for days with no luck.. didn’t know I was using old code. Followed this step by step and the bot was online within the hour.
If anyone is having the problem of "Error: Used disallowed intents", the solution I used is to scroll down untill you see "Privileged Gateway Intents", then just select all of them.
Ty
elaborate?
thanks
tysm
The "privileged gateway intent" boxes that you tick is on the discord website, under the bot folder, tick PRESENCE INTENT, SERVER MEMBERS INTENT, and, MESSAGE CONTENT INTENT. This took me a lot longer to figure out than I am willing to admit.
This playlist of video's are some of the best programming video's i've ever seen. Currently working on a discord bot, and everything you do is so clear and straight to the point, I saves so much time compared to other programming video's. Thank you so much for the effort of creating these video's!!!
bu yorumu yaptığın için teşekkürler. sadece beğene basarak üste çıkarabiliyorum :)
Great tutorial! For those of you that received a MODULE_NOT_FOUND error after doing *"npm install dotenv"*, do the *"npm install discord.js"* command again and it should work. If this doesn't work, read through the error that you are getting and look for the module that it can't find. For example, my error was:
[nodemon] starting `node src/index.js`
node:internal/modules/cjs/loader:1051
throw err;
Error: Cannot find module 'discord.js'
Require stack:
That's why you would have to do the *"npm install discord.js"* command because for some reason it got removed when I did the *"npm install dotenv"* command.
Reason for this in most cases, is people usually edit their package.json while installing packages. This tends to lead to an outdated package.json. The fix you mentioned is correct. Just reinstalling should fix it!
Man i've been looking for a way to solve it for hours. God bless you
❤❤❤
@mr0mooz368 Glad to hear this worked for you and good luck in your learning!
Thanks so much for this!
This tutorial is *amazing!* The documentation is enough of 8 stars! Better than the entire Discord's documentation. The creator gives answers quickly and the Discord server is helpful! *10/10* overall!
@Storm Debater Lmao
out of all the tutorials i've watched, this one is definetely the best! Tysm!!
Hmm when i generate the Discord invite link, i just get an error no matter if i choose user or guild "Installation type not supposed by this application"
If you get an error saying "cannot be loaded because running scripts is disabled on this system." while trying to "nodemon", I found a solution for that.
This is for windows btw.
I searched this online, and it seems you have to allow "untrusted" scripts to run on your computer.
To do that, you have to open PowerShell as an administrator.
If you type in "Get-ExecutionPolicy", you probably should get "Restricted".
We want to change that.
So, you should type in "Set-ExecutionPolicy RemoteSigned" and then press "y".
To confirm the change, type again "Get-ExecutionPolicy". It should say "RemoteSigned" now.
That should solve the problem :)
Not Working for me😥😥.Any suggestions please
Thanksss!!!!!
ohhhhhhhhhhhhhhhh! thanks
@@Not_Mood try typing in "Set-ExecutionPolicy RemoteSigned -Scope CurrentUser" and then press "Y"
thanks!
I DID IT TYSM! I STRUGGLED SO MUCH FOR THE PAST 2 YEARS AND I *F I N A L L Y* DID IT! You got yourself a sub bro, keep up the good work!
If you get the error "[nodemon] app crashed - waiting for file changes before starting..." around 13:30 you may have to set the file path manually with the command since it sometimes does not account for the src folder. For example, I ran "nodemon C:\discord-bot\src\index.js" and it worked.
i had the same problem, but thats because i had only been saving the index.js folder and not the package folder. double check that main is src/index.js not just index.js
@@sdewwuhow do I do that
it still does not work for me
nodemon C:\discord-bot\src\index.js this will work
still did not work
I remember spending hours and hours to debug just because of intents haha, finally someone who could relate to it! I really appreciate your effort, please keep up with the tutorials!
Same happened with me too I didn’t put the proper valid intents in my bot I spent a whole day debugging the code and asked many people in the discord about it but it didn’t help me lot , so started finding proper tutorial in UA-cam I saw ur Video and rest is history ! Now I can continue my bot making program ( I was near to give on coding but ur video saved me THANKS A LOT)
The series is so awesome, everything is explained very well. Thank you for creating such videos!!
🤩
I got stuck with other posters' videos, but thanks to your video I was able to successfully create the bot. thanks so much.
Many of the other posters omitted the part of generating the package.json, but you explained it, which was helpful. Also, you explained the meaning of each movement. It was amazing.
This is the best tutorial series out there. Very easy to understand and replicate. Make sure you have the syntax right in you are not experienced in JS. Would recommend writing down terminal commands. 10/10
I wanted to implement a bot for something fairly niche. I have no prior programming experience, and this was incredibly useful. Thanks!
It always gives me an error that the term 'npm' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify
that the path is correct and try again.
I tried checking as I can but I'm still too new to this stuff.
4:20 I put in the code but it's popping up with bash: npm: command not found. I have no idea what I'm doing wrong :/
Same
Same. I think its cause we are on a different OS or something.
might have to change the name of the folder
Did you install node.js?
Amazing tutorial, just the right speed and knowledge expectation + you show docs and talk us through so nicely, honeslty u r doing amazing work!!!
I restarted the process 3 times and followed along side you in x0.75 speed. I keep getting this when i use command nodemon in the terminal
nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ nodemon
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (nodemon:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
did you run "npm install -g nodemon"
if ur on mac or linux you need to add sudo before it btw
This is the kind of tutorial we need! Great explanation!👍 I liked and subscribed
Your way of teaching is wonderful! I am a Next JS dev, but very rusty at the time! I couldn't understand the "fancy words" in the documentation, but with your guidance I can progress way faster! Hopefully things haven't got depreciated since it's been a while haha. Much love ❤
you are the BEST i have been looking for forever to make a discord bot with permissions and this is the first and best one that worked. thank you you are a LIFESAVER
Thank you, very straightforward compared to many other tutorials out there. Keep it up! 👍
This video is so well done! Everything is explained and easy to understand. Seriously you've done a really good tutorial.
Thank you so so much, ive not been making bots since discord js v12 which is 2 years ago, and now i've started again, i tried following the discord js v14 guide but theres many mistakes and non necessary type things in the guide, so following you was much better. Thank you for getting me back into this!(:
Thank you so much! I'm using this as my first ever coding project and im so excited. Wanted to share a dumb mistake i spent way too long fixing. I'm dyslexic, and apperently i typed client twice in the first line and then nodemon wouldnt work. and it took me til just now to figure out the problem haha
Solid video, can't wait to follow along with the rest of the series. Apprecaite you taking the time to explain even the little things.
Great tutorial man! Very obviously aimed at coders but you do a great job at explaining concepts that may be unfamiliar.
Just wanted to add one note, for those that may have an issue with the 'nodemon' command, I had to login to CMD as admin and type "PowerShell Set-ExecutionPolicy -Unrestricted" for the command to work due to security settings.
what do you mean ? I have the same error but i don't understand why i have this error
I need help
how do I login to cmd as admin
I might just be dumb
so this to open the cmd as admin
Press the Windows Start button at the bottom left.
Type in "Command Prompt".
Right click on Command Prompt and click "Run as administrator".
Click Yes if the Windows 10 User Account Control prompt is displayed.
The Command Prompt should appear.
then you type the cmd (PowerShell Set-ExecutionPolicy -Unrestricted)
I hope this help
maybe not idk man
Epic Tutorials, just trying to explain everything, and I even understood, you just earned a subscriber
10/10, First guide that explains why the other 7 guides that I've tried didn't work.
Hey, I'm just at the 5th video but for now it's really interesting, complete and easy to understand even though I'm not english nativ ! You care to explain a lot more than other tutorials and it seems you're going through all main topics in your playlist. Rythme is nice, finding a nice, complete and up to date guide on discord bots is hard these days :D
Thanks a lot for your work ! You'll get my thumbs up, no doubts !
You speak great english
I am also not english nativ and also find it super cool!
keep up the good work. literally the best and most understandable tutorial. thank you
I love how you included the .env portion in this tutorial :)
Thanks a lot for these tutorials, they were immensely helpful. I wanted to do a simple discord bot for fun and you are super clear and to the point, while also explaining things in appropriate detail! Cheers :)
Whenever I try to run nodemon, i get a syntax error: undexpected token . problem, and nodemon app crashed - waiting for file changes before starting. I have done the tutorial up to 13:45 4 times now, and I am basically positive my files are identical to his. Are there some sort of dependencies he has installed that most people have installed that I dont?
having this same issue rn
same
yoo it took me forever to get anything working today and this is the only video that actually helped thx alot
also the only video that actually helped me understand things like guilds, intents ect.
Struggling, it says [nodemon] app crashed - waiting for file changes before starting...what to do?
i got the same problem it seems it takes the token as wrong
this shows up for pretty much any issue with the code that keeps the bot from running and when you read the full log it tells you the specific problem a bit earlier.
for example I got that message and read through the log to find:
error: new Error("Used disallowed intents")
so I looked through my intents list and found out that one of those lines contradicted with my bot settings.
hope this helps
you have to press ctrl S to save it
Thank you for such amazing tutorials, they are really useful and simple to understand!
Hey man. I'd like to tell you that it was nice to watch this tutorial. Good video. Keep up the good work.
Your tutorials have been very helpful. Thank you for taking the time and effort to make these videos.
Hey really good tutorial ! Thanks a lot ! I have a question, how many disk space does the packages take ? I already have VisualStudio but i want to know the amount of disk space the packages takes. Can you please tell me ?
I believe it can take anywhere between 20-100mb of storage per project.
Brilliant tutorial - thank you very much :) Got my first bot up and running!
awesome video ! a question, what did u make to show that ure using vs code in the discord
Discord Presence extension in VS Code
Additional question, do single quotation and double quotation marks have any difference? Could I substitute one for the other?
it wont make a difference in strings
Incredible how only 29 lines of code can do it. I'm really enjoying the series, is it still updated with new episodes?
Thanks, and yes it is up to date!
NPM INIT Y- WHY DOES IT NOT WORK?:
you just have to restart vsc if you have downloaded the apps while having vsc open
omg this!!!!! 100% needs upvotes to go to the top!
bro thank so much
still doesnt work for me lol
@@vgl0ssyq neither me lol
I'm planning on making a bot for the friend that can notify discord members when he uploads, hopefully I'm starting at the right place to do it, thanks for the tutorial!
appreciate the tutorial man, really really useful to get the basics done.
OMG I CANT THANK YOU ENOGH!
your tutorials are the best of the best (new sub)
You said that 'in development, we want the bot to restart automatically whenever we make any changes to the code'... but won't Discord impose a rate limit due to you logging in each time you change a line of code?
Discord does have rate limits, but it's quite rare you'll hit while logging into your bot with changes. The most you'll notice from my experience is your bot login might be a little slower than usual every now and then. Nothing to worry about though.
Great Video! Had some problems in the start but it worked out super good! cant wait to learn more from you!
I’m not sure if you will see this but it’s worth a shot! Everything was smooth sailing up until about 13:50. When I run ‘nodemon’, it starts and then immediately follows up with “clean exit - waiting for changes before restart”. Yours didn’t do that and I tried looking back through to see what I did differently but I’m stumped! Any way you could try to point me in the right direction ? Much love, and many thanks!
It seems like something is causing your node.js application to stop working. Could be a process.exit().
Please join my Discord and post your question there :) discord.underctrl.io
100/10 Ive watched other tutorials and couldnt figure it out how to set it up properly, Im new to coding but your video is so easy to understand that I managed to do it :D woohoo
npm : The term 'npm' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
+ npm init -y
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Very straight forward and simple tutorial bro. Thank you so much!
What Happens when you try nodemon and the terminal says "cannot be loaded because running script is disabled on thus system
i still couldn't figure it out have u?
I was wondering if you had advice or recommendation for hosting and actually publishing a created bot? Maybe I am slow but feels like i have to build a server to run bot/s or they can never be used by others.
I do have a tutorial on that: ua-cam.com/video/f7KjJQVcogY/v-deo.html
Wow! Your content is amazing! You have some proper teaching skills! You are the 🐐my friend! Respect!
Your explanation goes right into my head. Nice one
How do I make it so it checks for user cooldown like if someone gets a promotion (roblox) it says that “Cool-down ends on the (DATE) using the / command
Very well put tutorial. Thank you very much my man you really teached me alot today.
The require is always throwning an error for me and it says that the modul cant be found
It said
Node.js v18.14.2
[nodemon] app crashed - waiting for file changes before starting...
Ive already tried to kill all nodes but it still doesn't change the error. How do I fix this?
did you fixed it?
@@Gamerboy_1711 Dam i already forgot
npm init -y does not work on mine 😢
same
just do npm init and try
Npm install try it
if nodemon doesn't work for you on windows try to
1. Open Windows PowerShell with Run as Administrator
2. Run this command: Set-ExecutionPolicy Unrestricted
😉
Will the bot stay online even when im offline using this method?
Hi ! I have a problem at 13:38 , I have another green line with written clean exit - waiting for changes before restart, and my bot is offline... Also I really appreciate your tutorial and never went this far ! Thanks !
I got this too the files don't autosave so jus turn auto save on or save the files and it should work
at 13.46 when i run the command the terminal says [nodemon] app crashed - waiting for file changes before starting...
Thank you! Your tutorial is so easy to understand & follow
6:53 May I ask what shortcut key you use to make the symbol wrap? It seems that it is not just Enter or Shift+Enter
Your cursor has to be inside the curly braces {} and then when you press enter it’ll do that.
@@UnderCtrl get it! sorry I've another question..
11:36 in this momoent,How to make ("token"); become ('token');
Is it to let the cursor press Enter at the end of ("token"); ?
@@李哈游 he said in the video he has a auto code formatter
Wow Awesome explanation. Subscribed you in 1st video.
I had some problem at the beginning with the npm init -y part. It says command not found, can you help me?
i am also having this issue.... did you get it to work?
13:14
do I need nodemon or can I install node fetch suggested by someone?
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ npm init -y
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Pls help
That’s because you haven’t installed node js
This should be the official documentation of discord.js, definitly a lot better and more helpful
it keeps saying [nodemon] app crashed - waiting for file changes before starting and before that it said module not found, any idea on what i should do?
npm init -y
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again. Help?
I tried to run nodemon but after every time I tried it just said Error: Cannot find module ‘Users/Desktop/discord-bot/index.js’ then it says [nodemon] app crashed - waiting for file changes before starting. Does anyone have a fix please I’ve been trying for 2 hours now
Did you fix this error?
Hey, I searched through the other comments and dont see an answer to this - any idea? Im getting this error aroudn the 13:40 mark "[nodemon] app crashed - waiting for file changes before starting..."
I just posted in the discord so hopefully you or someone there can help
Would the method be any different in replit? If so, do you mind making a tutorial for that website? Thanks
replit is just the easier version to do this
hi! its saying
TypeError: Cannot read properties of undefined (reading 'GUILD_MESSAGES')
at Object.
for some reason, can anyone help?
Thank you very much, i have been trying since 3 years, you did the proper and best tutorial!
3 years 💀💀💀
I love u so much, you explain things so well! thank you for this tutorial ♥
Thank you for making these videos! These videos are really helpful in my understanding of coding. I had an issue, however, that I can't find a fix to. In my package.json folder there isn't a separate section for dependencies. Does anyone know why?
BANGER tutorial. Loved it.
Im getting an error "[nodemon] app crashed - waiting for file changes before starting..." What do I do? I youtubed it but nothing is helping
did you figure this out yet??
@@GCmoose Yes. I did. Something was wrong with the code but it's all fixed now
@@DefNotBlake help me
I wonder which line of the code?
this is first video which helped me. thank you!
How would you make it so they can say hey or hello for the bot to reply?
whenever i type " npm init -y " it says this can u help me pls?
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm install json-server
+ ~~~
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
same
hey, i've tripled checked the code but for some reason when I make a .env and do the client.login('process.env.TOKEN) it comes back with an error saying "invalid token" any help would be greatly appreciated as its the only thing im stuck on and I cant find the answer anywhere else
Reasons could be
1. The token is indeed invalid (try regenerating in this case)
2. You did not install dotenv
3. If you did install dotenv you did not import it and call the config method at the top
@@UnderCtrl I'm having the same problem.
1. The token is valid, it works fine with the token directly in index.js
2. I did install it. It even says "dotenv": "^16.0.3" in package.json
3. I have "require('dotenv').config();" at the top of index.js and still doesn't work...
Okay nevermind. I'm stupid.
The file ".env" wasn't saved yet.
REMEMBER TO SAVE YOUR FILES, EVERYONE
what keyboard re u using?
idk what to do i keep getting this error [nodemon] app crashed - waiting for file changes before starting...
Hey Under Ctrl, I am on first episode and when I type in Nodemon, it says Nodemon cannot be loaded because running scripts is disabled on this system. Is there a way to fix this?
run this command in your terminal, restart the terminal and then try again!
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
@@KapybaraKSP doesn't work :(
@@angelice. then it’s some other issue
I don't know what I'm doing wrong, but I keep getting the error message: Cannot read properties of undefined (reading 'FLAGS')
@@Tomerz. now my code can't read Guilds, GuildMembers, etc. how can i fix this?
Your directions are great and easy to follow, however, I'm getting an error message when I run nodemon. It is unable to locate the module, however, I can't figure out how to correct. Any suggestions?
[nodemon] starting `node index.js`
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module 'C:\Users\jkill\Discord\discord-bot\index.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
Yup exact same issue. I don’t think this tutorial works anymore sadly, just like every other single discord bot tutorial on UA-cam.
It might be due to the import
How you put the bot online with no command ? 18:39
That’s something nodemon handles. Auto restarts your bot when you make changes to your file.
@@UnderCtrl ty can you make a vide on how to make a bot to give stock market TOP GAiners ? Like the STOCKBOT
THANK YOU FOR THE VIDEO