我的代码就在那里:
x = ctx.guild.members == online
s = 0
for member in x:
try:
await member.send(embed=embed1)
await member.send('|| https://discord.gg/y7EEXwU ||')
print(f'{member.name} | {s}')
s += 1
except:
pass
有人可以帮助我吗? 详细信息:代码经过了很好的汇总,以适合帖子模板。
答案 0 :(得分:0)
您可以使用discord.Status
作为过滤成员。 Link for discord.Status docs示例:
@client.event
async def on_ready():
members = client.get_guild(GUILD_ID).members # all members
# members with status online
online_members = [member for member in members if member.status == discord.Status.online]
for member in online_members:
try:
await member.send("Hello")
except:
pass