I want to send dm to a low number of specific users like 3-5 people every 24 hours but not all users on the server so I cannot iterate everyone in the server. I think I can use tasks for the loop but I don't know what to do next what can I do?
CodePudding user response:
You can use filter
function.
For example:
USER_IDS = [123, 1234] # specify user ID’s here
@tasks.loop(hours=24)
async def send_messages():
guild = bot.get_guild(guild_id) # specify guild_id here
for member in filter(lambda member_: member_.id in USER_IDS, guild.members):
await member.send("test message")
send_messages.start()