【发布时间】:2019-05-10 08:04:32
【问题描述】:
我觉得我做错了什么。如果我尝试使用在控制台中打印消息,它确实可以工作,但如果我尝试向 discord 发送消息,我无法让它工作。
import discord
import asyncio
from discord.ext import commands
import schedule
import time
TOKEN = 'xxx'
client = commands.Bot(command_prefix = '.')
@client.event
async def on_ready():
print('Bot Online.')
async def job():
channel = client.get_channel('XXXX')
messages = ('test')
await client.send_message(channel, messages)
schedule.every(5).seconds.do(job)
while True:
schedule.run_pending()
time.sleep(1)
client.run(TOKEN)
我修改了代码,但仍然收到此消息:
RuntimeWarning:从未等待协程“作业” self._run_job(job)
【问题讨论】:
标签: python python-3.x scheduled-tasks python-asyncio discord.py