Guias

Code a Discord Bot with JavaScript – Host for Free in the Cloud








Learn how to code a Discord bot using JavaScript / Node.js and host it for free in the cloud using Repl.it. You will also learn to use Repl.it’s built-in database.

🚨 At 13:44, Replit now has a new method for environment variables. Read what to do here:

🔗 Get 3 months FREE of the Hacker Plan on Repl.it (first 1000 people):

This course was developed by Beau Carnes.

🎥 Code a Discord Bot with Python Video:

💻 Full code on repl.it:

🔗 Online code editor:
🔗 Discord Home Page:
🔗 Discord Developer Portal:
🔗 Discord.js library:

Need help with this tutorial? You can ask questions here:

⭐️ Course Contents ⭐️
⌨️ (00:00) Introduction
⌨️ (01:38) Creating a Discord Server
⌨️ (02:27) Creating a Bot User
⌨️ (06:23) Starting a Project in Repl.it
⌨️ (08:37) Coding a Basic Discord Bot
⌨️ (15:44) Improving the Bot
⌨️ (26:35) Using the Repl.it Database to Store Bot Settings
⌨️ (46:08) Testing the Bot
⌨️ (50:22) Creating a Web Server for the Bot
⌨️ (55:06) Connecting Uptime Robot So Bot Runs Continuously

Special thanks to Repl.it for providing a grant that made this course possible.

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

And subscribe for new videos on technology every day:

Link do Vídeo






28 Comentários

  1. For anyone that is stuck on creating web server: Paste the code below

    const http = require("http");
    http.createServer((_, res) => res.end("Alive")).listen(8080)

    Add the code WITHIN the bot code, not a diff file.

  2. guys if any one have to run this in your local ide like vs code it need to be done likethis step 1 code step 2 install node step 3 run in your terminal for windows its power shell for linux its bash for other thing your installed in mac idk! step 3 go to that folder where it is saved search for your os online then type node xyz.js

  3. im getting this error,
    TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.

    at Client._validateOptions (/home/runner/funymaster2009/node_modules/discord.js/src/client/Client.js:548:13)

    at new Client (/home/runner/funymaster2009/node_modules/discord.js/src/client/Client.js:76:10)

    at Object.<anonymous> (/home/runner/funymaster2009/index.js:2:16)

    at Module._compile (node:internal/modules/cjs/loader:1101:14)

    any help?

  4. When I follow the instructions about require() method, I got the error returned "that the "require()" is no longer supported and i need to use "import()",but when I replce "require" with "import" nothing just happens. Please, help!!!

  5. Database statements give errors. kindly help out

    /home/runner/Encourage-discord-bot/node_modules/node-fetch/lib/index.js:1327

    throw new TypeError('Only absolute URLs are supported');

    ^

    TypeError: Only absolute URLs are supported

    at getNodeRequestOptions (/home/runner/Encourage-discord-bot/node_modules/node-fetch/lib/index.js:1327:9)

    at /home/runner/Encourage-discord-bot/node_modules/node-fetch/lib/index.js:1440:19

    at new Promise (<anonymous>)

    at fetch (/home/runner/Encourage-discord-bot/node_modules/node-fetch/lib/index.js:1437:9)

    at Client.get (/home/runner/Encourage-discord-bot/node_modules/@replit/database/index.js:20:18)

    at Object.<anonymous> (/home/runner/Encourage-discord-bot/index.js:25:4)
    })

  6. Can someone help me please ? At the end after creating "server.js" I have this error message

    Error: Cannot find module '/home/runner/DiscordBot/index.js'

    Require stack:

    – /nix/store/9ackq82lagfpsm625fa87k32fsf5gyk2-prybar-nodejs-0.0.0-74f34a6/prybar_assets/nodejs/module-context-hook.js

    – /tmp/prybar-nodejs-2758203936.js

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)

    at Function.resolve (node:internal/modules/cjs/helpers:108:19)

  7. Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/Lovers-Botjs/node_modules/node-fetch/src/index.js from /home/runner/Lovers-Botjs/index.js not supported.

  8. hey I have a problem/
    TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.

    at Client._validateOptions (/home/runner/FlamboyantEvergreenProfessional/node_modules/discord.js/src/client/Client.js:548:13)

    at new Client (/home/runner/FlamboyantEvergreenProfessional/node_modules/discord.js/src/client/Client.js:76:10)

    at Object.<anonymous> (/home/runner/FlamboyantEvergreenProfessional/index.js:2:16)

    at Module._compile (node:internal/modules/cjs/loader:1101:14)

Comentários estão fechados.