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

Wordpress sites

Learn how to code a Discord bot using Python and host it for free in the cloud using
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs:

Along the way, you will learn to use's built-in database and create a Discord bot that uses webhooks to connect with GitHub.

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

This course was developed by Beau Carnes.

🔗 Online code editor:
🔗 Discord Home Page:
🔗 Discord Developer Portal:

💻 Python server code for bot:
💻 Full code on

⭐️ Course Contents ⭐️
⌨️ (00:00) Introduction
⌨️ (01:18) Creating a Discord Server
⌨️ (01:52) Creating a Bot User
⌨️ (06:05) Starting a Project in
⌨️ (09:33) Coding a Basic Discord Bot
⌨️ (20:14) Improving the Bot
⌨️ (33:35) Using the Database to Store Bot Settings
⌨️ (56:09) Testing the Bot
⌨️ (58:42) Creating a Web Server for the Bot
⌨️ (1:03:36) Connecting Uptime Robot So Bot Runs Continuously
⌨️ (1:05:21) Creating a GitHub Discord Bot Using Webhooks

Special thanks to 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:

48 thoughts on “Code a Discord Bot with Python – Host for Free in the Cloud”

  1. Went through the first 20mins of this with my 13-year old and they are delighted and excited to have coded a live bot that does what they want on their discord servers. Great work with this tutorial. Thank you!

    1. @sktmd rmn Ironically this could be a bot’s comment attempting to create Discord on our peaceful thread.

    2. @kojo antwi you not being able to comprehend basic grammar doesnt make others bots

    3. Sebastian Creek

      @sktmd rmn
      So is this sentence grammatically incorrect?
      “Sorry I’m home late, someone was making a big ruckus at the store because they thought they were being scammed.”
      “Well were they being scammed? I’m curious now!”
      “Well were he/she being scammed? I’m curious now!”

  2. The .env file has changed since this video. Now they have a new section called secrets in the sidebar. In order to get the environment variable now, you need to “import os” and then you need to use os.environ(‘TOKEN’) to take the variable and use in the run command. I’m looking at 18:36 in the video rn.

    1. Bro i get this error but idk somebody help me
      File “”, line 8
      print(‘We Have logged in as {0.user}
      SyntaxError: EOL while scanning string literal

    2. @Gotreet Lord from looking at that error, you dont have a closing parenthesis for the print statement. So just add a “)” at the end of the line

  3. Hey, I’ve been learning python for bot making. This helps a lot, I would recommend it to other people!

  4. If you get an error when you use
    options = options + db[“encouragements”]
    I has an error using this
    try using
    options = options + db[“encouragements”].value
    I think why by adding .value it works is because in the earlier statement we were trying to concatenate a list/array with a dictionary kind of thing which had {value=[//Your message]}. By adding value I was able to concatenate the message to the database.

  5. This is probably the most detailed discord bot tutorial that i’ve ever seen! Thank you Beau for spending you time and helping beginners learn coding!

    1. This is off topic but I found a playmobil set in Brazil that costs $140.99 with $7.23 shipping fee.

  6. Thanks for this – as a software developer (who works mainly in the linux/cli environment) – a lot of this stuff is new to me. So I really appreciate you walking us through it step by step.

  7. What a fantastic video. Thank you so much for this! I worked out the little things that had been depreciated, and a couple of times my indents were off which was throwing me off…

    I used to code in C# a couple of years back, but no experience in Python. Now I’m really warming up to it! Thanks again, the bot works great.

  8. This is such a great tutorial! Literally people with 0 experience in discord bots can start, maybe even people totally new to python. And it includes the whole package of all the essentials, the framework. Most YouTubers split this up in like a gazillion videos in a playlist, but this video absolutely dominates them all!! Thank you so much!!!

    1. Well if you know nothing abour python, jumping straight into making discord bots isnt gonna help, heck, i made a few programs in python and im still not gonna be able to code a bot all by myself.

  9. Hier könnte ihre Werbung stehen

    Can you pls make another part?
    There are so many things we still need:
    How to React
    How to Reply
    How to Send Images
    How to get Data like Names
    How to apply Roles

  10. Very nice tutorial, but I have one observation regarding web server. Flask let you know by default that it’s integrated web server is for development only. In case of production, they suggest you to use different wsgi server, like gunicorn? Can you extend this tutorial to include gunicorn, or something more “production” ready. Thanks for great tutorial video. Cheers!

  11. This man just made my day. I always wanted to created a bot but I just started learning Python and I’m still learning basics and control structures. So I don’t know where to start but this guy helped me how to do the bot in every single step and yes I did it! Thank you so much, I hope you’ll do some great videos like this which are very helpful! 👏

  12. HealthyHP The 2nd

    Want to add, thank you for this tutorial, its still super helpful in 2022 ( with some fixes ) and gave me an idea on how to use Webhooks and so much more, thank you for all the free resources! 🙂

  13. I was going to make a discord bot and searched up a tutorial and found this masterpiece thank you for making this 🙂

  14. Amazing turtotrial. In one hour I’ve learned how to use discord bot documentation and keep it running 24/7 as well as having a free database! You sir are an angel walking in man’s shoes.

  15. If anyone is having a problem with adding new encouragements, you need to change the line:

    options = options + db[“encouragements”]

    change it to:

    options = options + list(db[“encouragements”])

    That will fix the error: TypeError: can only concatenate list (not “ObservedList”) to list

Comments are closed.