python - 对于不和谐的python,如何每x秒打印一条带有任务的消息?
问题描述
例如,我试图每 10 秒在普通聊天中打个招呼。我怎么做?我正在使用任务功能。
channel = client.get_channel('channel id')
@tasks.loop(seconds=10)
async def sendmessage():
await channel.send("hello")
解决方案
您可以使用 `.start() 启动任务
channel = client.get_channel('channel id')
@tasks.loop(seconds=10)
async def sendmessage():
await channel.send("hello")
sendmessage.start()
推荐阅读
- matlab - 用 subsasgn 调用 Matlab 的 memmapfile
- python - Jupyter Notebook - 属性错误:“模块”对象没有属性“F_OK”
- chart.js - AmCharts:带有子类别的聚集条形图
- android - 在 build.gradle 文件中混合 android 依赖版本错误消息,但是找不到不同的依赖项
- spring - Spring集成消息丢失场景
- javascript - 如何使用 UserName 获取该用户的用户名和头像
- ansible - 根据 Ansible / jinja2 中的变量过滤列表
- python - tkinter 画布封闭的形状根据标签在点击时更改填充
- android - com.android.builder.internal.aapt.v2.Aapt2Exception:Android 资源链接在 android 3.2.1 SDK 28.0.3 上失败
- java - 树状连接的算法?