How to Build a Discord Bot – Full JavaScript Chatbot Tutorial



Learn to code a Discord bot with JavaScript using Node.js.

πŸ”— Written Tutorial – https://www.devdungeon.com/content/javascript-discord-bot-tutorial
πŸ”— Unicode Emojis – https://unicode.org/emoji/charts/full-emoji-list.html
πŸ”— Official Documentation – https://discord.js.org

Tutorial by Dev Dungeon. Check out their YouTube channel: https://www.youtube.com/channel/UCgkG68BiCngkoV7I2BLtAVg

Learn to code for free and get a developer job: https://www.freecodecamp.org

Read hundreds of articles on programming: https://medium.freecodecamp.org

And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

source

This Post Has 38 Comments

  1. Ezii VPS

    If you encountered an error with npm install discord.js press ctrl + r and type where npm. After that restart your computer and you should be all set!

  2. mayo

    My bot won't even come online. It does nothing. I have all the correct programs installed and updated but nothing works.

  3. Flooby x3

    I've been following his code to a tee and it comes back with an error "Unexpected end of input"….

  4. Sureal

    So uh idk if this is still valid but great vid I don’t have a computer tho so yea

  5. 19_588 suresh

    10:15 client.guilds.cache.forEach()
    10:44 guild.channels.cache.forEach()
    12:00 let generalChannel = client.channels.cache.get()

    12:40 const attachment= new Discord.MessageAttachment()

    18:36 let customEmoji=recievedMessage.guild.emojis.cache.get()

  6. TheBoyzGotMe

    Can I have the discord link cause the one that you showed is not working and when I was trying to code with node it shows an error.

  7. When Im writing node.js, there is no message being displayed…moreover the bot is not going online…please help me out

  8. Lud

    it doesen't get online i wrote all letters

  9. Monomilo

    how to make looping i try some code. its run only one time.

  10. Sniper Os

    Mcafee is blocking installation of node js saying somebody is trying to hijack your computer

  11. Milk Shake

    it doesnt work for me when i use clients.guilds.forEach()

  12. Indero

    it doesnt set the activity for me or send hello world or show me all the servers its in, please help

  13. Trash Can Gaming

    i currently have a custom dice app that i want to integrate into a discord bot. is there a way to link said diceapp to a bot so i don't have to rewrite code?

  14. Daryl Lackey

    I made it up to 8:16 before encountering a problem. My bot connected but didn't appear in my discord channel on the right side bar as either ONLINE or OFFLINE. The system did say "My Awesome Bot just landed." But when I try to @ my bot, she (my bot is a girl) is not available as a selectable member.

    Node version is 12.16.3

    What did I miss?

  15. Sweer

    you not using semi-colons makes me angry and I dont know why

  16. MASTER DELUXE

    Bruh everything different in 2021 it outdated how to fix help πŸ™

  17. Had

    For some unknown reason, when I try to use “client.channels.get“ I get the error "client.channels.get is not a function", with an arrow specifying that “get“ is causing that, what's the way behind that?

  18. BGBMO

    i need help when i ran the "node my_bot.js" it did nothing and i had no warning or anything

  19. Swaroop D.

    Note for all devs watching this video in 2020-2021:

    please put .cache after .guilds or .guild.<whatever>.cache
    discord has updated this so you might run into errors if you don't put it

  20. PRoton_208

    When i start doing it it shows that unexpected token '-'…How do we fix it?

  21. Raz MaTaz

    TypeError: client.guilds.forEach is not a function.

    The entire portion of the video that deals with forEach doesn't work anymore.

  22. Sanchit Dhauchak

    My code at 7:58 doesn't work. I tried everything u said in the vid as well as the comments.
    HELP!

  23. aiden hess

    having trouble with .send around the 12 minute mark, any ideas?

  24. -mE1E the

    i have this error and i don't know how to fix it
    Error:
    throw new TypeError('CLIENT_MISSING_INTENTS');

    ^

    TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.

    at Client._validateOptions (C:DiscordBotnode_modules←[4mdiscord.js←[24msrcclientClient.js:544:13)

    at new Client (C:DiscordBotnode_modules←[4mdiscord.js←[24msrcclientClient.js:73:10)

    at Object.<anonymous> (C:DiscordBotbot.js:2:16)

    ←[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)←[39m

    ←[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)←[39m

    ←[90m at Module.load (node:internal/modules/cjs/loader:981:32)←[39m

    ←[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m

    ←[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)←[39m

    ←[90m at node:internal/main/run_main_module:17:47←[39m {

    [←[32mSymbol(code)←[39m]: ←[32m'CLIENT_MISSING_INTENTS'←[39m

    }

    πŸ™

  25. rlyalx

    I try to do "node my_bot.js" but it comes up with "TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client" why?

  26. Vyliad

    I keep getting this error, what do i do?
    C:UsersEnderDesktopmy_botnode_modulesdiscord.jssrcclientClient.js:544
    throw new TypeError('CLIENT_MISSING_INTENTS');
    ^

    TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
    at Client._validateOptions (C:UsersEnderDesktopmy_botnode_modulesdiscord.jssrcclientClient.js:544:13)
    at new Client (C:UsersEnderDesktopmy_botnode_modulesdiscord.jssrcclientClient.js:73:10)
    at Object.<anonymous> (C:UsersEnderDesktopmy_botmy_bot.js:2:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
    [Symbol(code)]: 'CLIENT_MISSING_INTENTS'
    }

  27. weirdthadoe:

    my bot are not connect with my code.i mean cannot find module

Leave a Reply