Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 具有用户令牌的guild.members不工作_Python_Python 3.x_Discord_Token - Fatal编程技术网

Python 具有用户令牌的guild.members不工作

Python 具有用户令牌的guild.members不工作,python,python-3.x,discord,token,Python,Python 3.x,Discord,Token,我正在制作一个Discord机器人,希望使用guild.members获得所有成员的列表。我遇到了一个问题,即guild.members只返回bot本身,而不返回服务器中的任何成员 我尝试的是在我的代码和Discord developers门户中启用意图,但它仍然没有做出更改 我的问题是,我试图使用guild.members使用用户令牌,但它不起作用 我的代码: import discord from discord.ext import commands from discord.ext.co

我正在制作一个Discord机器人,希望使用guild.members获得所有成员的列表。我遇到了一个问题,即guild.members只返回bot本身,而不返回服务器中的任何成员

我尝试的是在我的代码和Discord developers门户中启用意图,但它仍然没有做出更改

我的问题是,我试图使用guild.members使用用户令牌,但它不起作用

我的代码:

import discord
from discord.ext import commands
from discord.ext.commands import bot
from discord.flags import Intents

intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!',intents=intents)
guild = bot.get_guild(790189441695350807)

@bot.event
async def on_ready():
    await uwu()

async def uwu():
    for i in guild.members:
        print(i)
bot.run(LmaoWhyYouTrynaStealMyToken>:c)

一旦你运行了机器人,它就会帮你完成任务。

帮会没有定义?另外,LmaoWhyYouTrynaStealMyToken>:c是无效的syntax@ForceBru这只是为了隐藏api标记定义,我忘了将其添加到堆栈溢出代码中。您在这里尝试了这些答案吗?答案很好。但请在代码周围添加一些文字,以帮助OP理解您的答案。这鼓励他们不要复制/粘贴答案。非常感谢。
intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!',intents=intents)
guild = bot.get_guild(790189441695350807)

@bot.event
async def on_ready():
    for i in guild.members:
        print(i)

bot.run("YOUR TOKEN")