@client.command()
async def members_info(ctx):
server_members = ctx.guild.members
data = "\n".join([member.name for member in server_members if "test" in member.roles])
embed = discord.Embed(title = f'Участники сервера', description = f"{data}", color = discord.Color.purple())
只输出带有标题和颜色的空嵌入消息,没有描述 我不知道我应该做什么-_-
答案 0 :(得分:1)
您可能错过了 members
意图。这意味着除非您执行直接 HTTP 请求,否则不会将成员加载到缓存中。启用:
首先在 dev portal 上启用:
第二次订阅discord.py:
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(intents=intents, ...)