到目前为止,这是我想要的...可以在我想要的延迟秒数内正常工作,但是如何添加时间模块或shedule模块以使其正常工作。 万一我希望机器人每24小时发送一次消息
import discord
import asyncio
from discord.ext import commands
import schedule
import time
TOKEN = 'xxxxx'
client = commands.Bot(command_prefix = '.')
channel_id = '515994xxxxx5036697'
@client.event
async def on_ready():
print('Bot Online.')
async def alarm_message():
await client.wait_until_ready()
while not client.is_closed:
channel = client.get_channel(channel_id)
messages = ('test')
await client.send_message(channel, messages)
await asyncio.sleep(5) #runs every 5 seconds
client.loop.create_task(alarm_message())
client.run(TOKEN)