每 15 分钟从数据库中删除一次数据,但出现错误 -- Discord.py
Drop data from database every 15 mins, but getting an error -- Discord.py
例如,我有一张名为 'JIMR1' 的卡片,每隔 15 分钟它就会从数据库 table 中删除一个代码。当我 运行 此代码时,它显示错误 can't send non-None value to a just-started coroutine
。我添加了打印,它显示代码没有任何问题,但只有当我尝试发送代码时才会出现问题。
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(minute='0, 15, 30, 45'), args=[channel])
async def cardDrop(self, channel):
cards = db.column("SELECT Code FROM cardsHand")
card = random.choice(cards)
print(card)
await self.client.fetch_channel(channel).send(card)
await self.client.fetch_channel(channel).send(card)
将其拆分为
channel = await self.client.fetch_channel(channel)
await channel.send(card)
例如,我有一张名为 'JIMR1' 的卡片,每隔 15 分钟它就会从数据库 table 中删除一个代码。当我 运行 此代码时,它显示错误 can't send non-None value to a just-started coroutine
。我添加了打印,它显示代码没有任何问题,但只有当我尝试发送代码时才会出现问题。
@commands.command()
@commands.has_permissions(administrator=True)
async def startc(self, ctx):
channel = ctx.channel.id
self.client.scheduler.add_job(self.cardDrop, CronTrigger(minute='0, 15, 30, 45'), args=[channel])
async def cardDrop(self, channel):
cards = db.column("SELECT Code FROM cardsHand")
card = random.choice(cards)
print(card)
await self.client.fetch_channel(channel).send(card)
await self.client.fetch_channel(channel).send(card)
将其拆分为
channel = await self.client.fetch_channel(channel)
await channel.send(card)