How to Host a Discord Bot on Heroku for Free - Discord.py Rewrite Tutorial #5

Tech With Tim · 204K views · 2019 · 14:40

Open on YouTube

Cloud, DevOps & reliabilityPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when someone asks how to keep a discord.py bot running 24/7 or how to deploy it on Heroku.

Recommended by 6 people across 5 different months, 2020 to 2022.

What it is

A 2019 Tech With Tim tutorial, part of his discord.py rewrite series, that walks through hosting a Python Discord bot on Heroku's free tier. It covers setting up the Heroku app, preparing the project files, uploading the code, and switching the bot on.

What people said

Recommends Redfer · 2020-07 · Stack Overflow · on “How do i make a discord.py bot run 24/7 but still be able to edit it?”

For hosting the bot you could use heroku and every time you change something you could push it like using a git repository. Reference for hosting on heroku: [this video] and as for the editing 24 hours you should take a look at using cogs. import os import discord from discord.ext import commands from discord.ext.commands import Context from dotenv import load_dotenv, find_dotenv load_dotenv(find_dotenv()) BOT_TOKEN = os.getenv("BOT_TOKEN") client = commands.Bot(command_prefix='.') @client.command() async def load(ctx: Context, extension): client.load_extension(f'cogs.{extension}') await ctx.send("Loaded Cog") @client.command() async def unload(ctx: Context, extension): client.unload_extension(f'

Recommends Aditya Tomar · 2021-02 · Stack Overflow · on “Heroku Discord Bot Offline When Deployed?”

I'm pretty sure it is case sensitive. If you're confused, you can watch this [this video] which provides a complete walkthrough on how to set up a bot on Heroku; it's the video I used to get started. Keep in mind one thing, however, that in the video, he puts `git+ [LINK] in his requirement file, which is incorrect as someone pointed out in the comment section. Rather, you would put in `git+ [LINK]

Recommends Aditya Tomar · 2021-02 · Stack Overflow · on “Heroku doesnt run my python app but app working well locally”

refer to this video [this video] to get a full walkthrough on how to set up your bot on Heroku. Keep in mind that at timestamp 6:36, he puts `git+ [LINK] in his `requirements.txt` file. However, that should be replaced by `git+ [LINK] which is the correct version of the git repository. Follow all the instructions in the video and you should be able to set it up properly- it worked for me. Good luck!

Recommends Reza Rahemtola · 2021-08 · Stack Overflow · on “How do I schedule a function to run everyday at a specific time in discord.py?”

For future people facing the same problem, the above answers using Tasks [LINK] are correct, but depending on the hosting service you are using there might be an easier solution. A popular choice is Heroku [LINK] , you can find multiple tutorials to setup your bot like this one [this video] . Then you can use the Heroku Scheduler [LINK] add-on: [LINK] to run your bot at a specified time : [LINK] and that‘s it, if you want to run a specific function in your bot you can specify arguments in the command and catch them in your code instead of just python bot.py like me.

Recommends Yash Verma · 2021-10 · Stack Overflow · on “remote: -----> App not compatible with buildpack: heroku error while hosting a discord bot”

i wanted to host my discord bot on heroku i have followed and youtube video till here [this video] but i don't know what to do to fix this error full Enumerating objects: 6, done. Counting objects: 100% (6/6), done. Delta compression using up to 4 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 2.68 KiB | 2.68 MiB/s, done. Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-20 stack remote: -----> Using buildpack: heroku/python remote: -----> App not compatible with buildpack: [LINK] remote: More info: [LINK] remote: remote: ! Push failed remote: ! remote:

Recommends mawerty · 2022-06 · Stack Overflow · on “How do I make my discord.py bot 24/7 which I have coded from VS code”

You should check out this great tutorial from Tech With Tim where he explains how to host a bot 24/7 on heroku for free. [this video]

Recommends Emrejik · 2022-06 · Stack Overflow · on “How to make Client run always (Discord.py)”

You should search for the hosting solutions, but for now, you can watch the Tech With Tim videos [this video] which would give you an idea.

Cites Carter Michaelis · 2021-01 · Stack Overflow · on “Programming a Discord bot in Python- Having some trouble hosting my bot on Heroku”

I've been trying to host my bot on Heroku, (followed this tutorial: [this video] ). Everything appears to be fine, but it does not work. The bot does not come online. Here are the logs if it helps: [LINK] Not quite sure what's wrong. I'm new to programming, so any insight would be greatly appreciated!