'Discord bot is still offline
To launch my discord bot, I followed the way using Heroku but... In Heroku, main.py is on, but my discord bot still offline.
I tried to change main.py with the code provided by default to see if there was a problem with the code I wrote, but it still didn't work.
import discord
from discord.ext import commands
import os
client=commands.Bot(command_prefix='!')
@client.event
async def on_ready():
print("Bot is ready")
@client.event
async def on_member_join(member):
print("A wild",member,"appeared")
@client.event
async def on_member_remove(member):
print("The wild",member,"disappeared")
@client.command()
async def ping(ctx):
await ctx.send(f"Hey! I am up and running with a ping of {round(client.latency*1000)}ms.")
access_token = os.environ['BOT_TOKEN']
client.run(access_token)
Heroku log
-----> Building on the Heroku-20 stack
-----> Using buildpacks:
1. heroku/python
2. heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
! Python has released a security update! Please consider upgrading to python-3.7.11
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.7.9
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Python app detected
-----> Using Python version specified in runtime.txt
! Python has released a security update! Please consider upgrading to python-3.7.11
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> No change in requirements detected, installing from cache
-----> Using cached install of python-3.7.9
-----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
-----> Installing SQLite3
-----> Installing requirements with pip
-----> Discovering process types
Procfile declares types -> worker
-----> Compressing...
Done: 54.5M
-----> Launching...
Released v35
https://discord-ysbot.herokuapp.com/ deployed to Heroku
Solution 1:[1]
Incredibly late, but it's because in Heroku you need a file called procfile (no file extension, just the bare name) with the content worker: python main.py
in your deploy app. After that, you go back to resources, where there's a thing called dyno. Here, you just enable it and your bot will be online.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jeremy Caney |