Discord bot不会在一夜之间保留字符串值

2024-09-29 23:27:36 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是我的代码

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = "!")

swingsMessage = "Update me"


@client.command()
async def swings(ctx):
    await ctx.send(swingsMessage)


@client.command()
async def update(ctx,*,message):
    if str(ctx.message.author) == "buysellshort#9420":
        global swingsMessage
        swingsMessage = message

用户类型!更新并在一行中显示一条消息,当用户键入时,bot将读取该消息!它将显示该消息。现在它可以工作了,运行正常,但第二天它又回到了“更新我”,它在Heroku上托管,是一个dyno机器人

有什么建议吗?是代码错了,还是你们认为它所在的linux机器刚刚关闭,这就是它被重置的原因


Tags: 代码用户fromimportclient消息messageasync
2条回答

在Procfile上,可以用worker代替web。这将摆脱30分钟的不活动状态,但要小心,因为它将全天候工作,并且可以很快消耗你的时间

看起来它在没有收到任何流量的30分钟超时后休眠

If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep. In addition to the web dyno sleeping, the worker dyno (if present) will also sleep.

Free web dynos do not consume free dyno hours while sleeping.

If a sleeping web dyno receives web traffic, it will become active again after a short delay (assuming your account has free dyno hours available).

Source

相关问题 更多 >

    热门问题