【问题标题】:Drop data from database every 15 mins, but getting an error -- Discord.py每 15 分钟从数据库中删除一次数据,但出现错误——Discord.py
【发布时间】:2021-05-17 21:22:04
【问题描述】:

例如,我有一张名为“JIMR1”的卡,每 15 分钟它会从数据库表中删除一个代码。当我运行此代码时,它显示错误 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)

【问题讨论】:

  • 总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是截图,不是链接到外部门户)有问题(不是评论)。还有其他有用的信息。

标签: python discord discord.py scheduled-tasks


【解决方案1】:
await self.client.fetch_channel(channel).send(card)

把它分成

channel = await self.client.fetch_channel(channel)
await channel.send(card)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-13
    • 2016-05-03
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    相关资源
    最近更新 更多