Discord.py 定时消息未执行

Discord.py Timed message is not executing

因此,我创建了一个执行重复消息的命令。为了测试目的,我在代码中将它设置为 10 秒,但我将每 4 小时循环一次消息。 运行 代码时我没有收到任何错误,但命令实际上并未执行。消息从未发送,我很困惑为什么,似乎无法弄清楚。

import discord
import discord.utils
import asyncio
import http.client
import aiohttp
import EZPaginator
import platform
import yaml
import os 
from yaml import load, dump
from discord.ext import commands
from discord.ext import tasks

intents = discord.Intents.default()
client = commands.Bot(command_prefix = '$', intents=intents)
client.remove_command('help')

@client.event
async def on_ready():
    print('ZOF BOT IS ONLINE!')

# Reoccuring Message Reminder

@tasks.loop(seconds=10) 
async def send_message(ctx):
    channel = discord.utils.get(ctx.guild.channels, name='reminders')
    remind = discord.Embed(title='**:rotating_light:ATTENTION ZOF:', description='Do not forget to donate to Fortress, Alliance tech, and Ruins!', color=0xFFFFFF)
    print('Reoccurring Message Sent.')
    await channel.send(embed=remind) ```

您需要启动任务功能,例如在 on_ready 事件中:

@client.event
async def on_ready():
    if not send_message.is_running():
        send_message.start()