使用discord.py的异步库discord.py-rewrite,或升级到discord.py==1.7.3。
示例:
import discord from apscheduler.schedulers.asyncio import AsyncIOScheduler client = discord.Client() scheduler = AsyncIOScheduler()
import discord from discord.ext import commands from apscheduler.schedulers.asyncio import AsyncIOScheduler bot = commands.Bot(command_prefix='!') scheduler = AsyncIOScheduler()
import discord from discord.ext import commands from apscheduler.schedulers.asyncio import AsyncIOScheduler bot = commands.Bot(command_prefix='!') scheduler = AsyncIOScheduler() async def my_func(): await bot.wait_until_ready() # do something scheduler.add_job(my_func, 'interval', minutes=1) scheduler.start()