Reputation: 45
So, I have created a command that executes a reoccurring message. I have it set to 10 seconds in the code for testing purposes, but I will have the message loop every 4 hours. I don't get any errors when running the code, but the command is not actually executing. The message never sends and I am confused as to why and can't seem to figure it out.
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) ```
Upvotes: 1
Views: 108
Reputation: 2917
You need to start you task function for example in on_ready
event:
@client.event
async def on_ready():
if not send_message.is_running():
send_message.start()
Upvotes: 1