运行时警告:从未等待协程'Command.__call__' self._run_job(作业)



尝试在工作日的固定时间发送嵌入,我可以使用asyncio睡眠每天运行(包括周末),但我想跳过周六和周日。现在我导入了schedule,并得到了错误

RuntimeWarning: coroutine 'Command.__call__' was never awaited
self._run_job(job)
import discord
from discord.ext import commands, tasks
from discord import Embed
import asyncio
import schedule
import time
import aiohttp
import tracemalloc

client = commands.Bot(command_prefix='..')
@client.command()
async def startpoll(ctx): #command name
#scheduler

#get channel
channel = client.get_channel(1039973136361345034)
# @everyone
if ctx.author.guild_permissions.manage_roles:
message = await ctx.send(f'{ctx.guild.default_role}')
# embed
description = []
embed = discord.Embed(title='**Daily Market Prediction**', description='<:Green:865709217678360636> **Bullish**nn<:Red:865709217980350464> **Bearish**', colour=6398207)

react_message = await channel.send(embed=embed)
await react_message.add_reaction('<:Green:865709217678360636>')
await react_message.add_reaction('<:Red:865709217980350464>')
while True:
schedule.every().thursday.at('23:18').do(startpoll)


schedule.run_pending()
time.sleep(1)

在23:18测试时期待一个帖子,但是一旦这个时间被击中,错误出现

我不知道调度库,但你应该看看disdiscord .py的任务扩展,它可以在特定的时间为你处理任务。

但是它很简单,你使用的库不能处理异步函数,命令实际上是什么…

只要使用上述扩展名即可。它内置在discord.py中,可以很好地与异步代码一起工作。如果你需要进一步的帮助,就问;-)

最新更新