python - Heroku 调度函数使用 Heroku Scheduler Python
问题描述
所以我正在使用 python.py API 开发一个不和谐的机器人,我试图让它每天使用 Heroku Scheduler 写一些东西,但我不能让它工作。主要问题是每个与 discord 交互的函数都需要是异步的,但不能在异步函数之外进行调用,如下所示:
async def hi():
channel = bot.get_channel(int(general)) #get the general channel from the id
await channel.send("Hello")
await hi() #not allowed (outside async func)
hi() #needs to be awaited
由于 Heroku Scheduler 需要提供运行整个脚本的作业(例如 python scheduler.py),因此我看不到使该功能正常工作的方法。因此,如果我删除 await 键盘,它显然不起作用。如果我删除了 async/await 关键字,它就不能与 discord 交互,因为它不是异步的,如果我将它保留在示例中,它会说我不能在异步函数之外调用 hi()。我该怎么做?提前致谢。
解决方案
推荐阅读
- assembly - 在 x86 组装中使用 PC 扬声器播放声音
- printing - 读取文件名时Python中的奇怪字符
- django - GKE 上的 Kubernetes Django Restframework
- unit-testing - 为使用 retryWhen 运算符的 RxJS 编写测试(了解与重试运算符的区别)
- linux - 在 RHEL 上找不到 netstat/net-tools 包
- angular - Angular 7 反应式表单下拉选项未更新
- cognos - Cognos:在报表工作室中创建自定义组
- c# - C# 程序监听 0.0.0.0 但不是 192.168.xx
- iframe - gcp 生成的签名 url 无法在 iframe 中使用 google doc 查看器
- mysql - Sql 易受攻击的脚本需要修复