本文介紹了如何在 discord.py 中獲取所有成員列表?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
@client.command()
async def members_info(ctx):
server_members = ctx.guild.members
data = "
".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())
只輸出帶有標題和顏色的空嵌入消息,沒有描述我不知道我該怎么辦-_-
Output just empty embed message with title and color without description I dont know what i supposed to do -_-
推薦答案
您可能缺少 members
意圖.這意味著成員不會加載到緩存中,除非您執(zhí)行直接 HTTP 請求.啟用:
It is likely that you are missing the members
intent. This means members are not loaded in cache unless you do a direct HTTP request. To enable:
首先在
第二次訂閱discord.py:
Secondly subscribe in discord.py:
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(intents=intents, ...)
這篇關(guān)于如何在 discord.py 中獲取所有成員列表?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!