How can this be fixed?
import discord
from discord.ext import commands, tasks
class func2(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.loop_task2.start()
@tasks.loop(seconds=210)
async def loop_task2(self):
ids = ['1263869253082157126', '772320334606368788']
for i in range(len(ids)):
user_id = ids[i]
user = await ctx.bot.fetch_user(user_id)
await user.send('Test message')
@loop_task2.before_loop
async def before_loop(self):
await self.bot.wait_until_ready()
def setup(bot):
bot.add_cog(func2(bot))
Error:
user = await ctx.bot.fetch_user(user_id)
^^^
NameError: name 'ctx' is not defined