为了启动我的不和谐机器人,我按照使用 Heroku 的方式进行了操作 但是...在 Heroku 中,main.py 已打开,但我的 Discord 机器人仍处于离线状态。
我尝试用默认提供的代码修改main.py,看看我写的代码有没有问题,但是还是不行。
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 日志
-----> 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