Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.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 Bot不发送DMS_Python_Discord.py - Fatal编程技术网

不协调Python Bot不发送DMS

不协调Python Bot不发送DMS,python,discord.py,Python,Discord.py,我在python中创建了一个discord bot,尝试向服务器中的每个人发送dms,但它不起作用 @client.command(pass_context=True) async def mass(ctx): guild = ctx.message.guild await ctx.message.delete() for member in guild.members: try: await member.send("

我在python中创建了一个discord bot,尝试向服务器中的每个人发送dms,但它不起作用

@client.command(pass_context=True)
async def mass(ctx):
    guild = ctx.message.guild
    await ctx.message.delete()

    for member in guild.members:
        try:
            await member.send("test")
            print(f"dmed {member.name}")
        except:
            pass

我正在使用最新的discord.py版本

您只需启用intent即可

intents=discord.intents.default()
intents.members=True#特权意图
client=commands.Bot(…,intents=intents)

还记得在中启用特权成员意图,

启用意图了吗?我启用了意图,感谢您告诉我欢迎堆栈溢出。“不工作”是什么意思?请阅读。