Karasmhi Asked:2022-08-01 17:08:30 +0000 UTC2022-08-01 17:08:30 +0000 UTC 2022-08-01 17:08:30 +0000 UTC 在一定时间后发送消息。不和谐.py 772 如何实现一定时间后发送消息?我需要机器人在一定时间后向频道发送消息。 python bot 1 个回答 Voted Best Answer RAINGM 2022-08-02T01:41:24Z2022-08-02T01:41:24Z 或者,您可以使用tasks import discord from discord.ext import tasks, commands class MyCog(commands.Cog): def __init__(self): self.printer.start() def cog_unload(self): self.printer.cancel() @tasks.loop(seconds=3600) async def printer(self): for guild in _bot.guilds: channel = discord.utils.get(guild.text_channels, id='channelid') await channel.send('Оповещение через каждый час!')
或者,您可以使用
tasks