Python Discord.py特权意图在_消息和命令停止工作时停止

Python Discord.py特权意图在_消息和命令停止工作时停止,python,discord.py,discord.py-rewrite,Python,Discord.py,Discord.py Rewrite,你好。我试图构建一个discord机器人,我大部分都是成功的,除了我无法进入成员加入和成员更新工作(他们甚至似乎没有注册用户进入或离开服务器,所以我认为我缺乏一些权限)。经过大量搜索后,我在discord.py文档中找到,并在我的代码中添加了intents位,on_member_join、on_member_remove和on_member_update起作用,但on_message事件和所有命令都不起作用(我在on_message的开头添加了一个打印,但什么也没发生)。 经过一些调试,我发现阻

你好。我试图构建一个discord机器人,我大部分都是成功的,除了我无法进入成员加入和成员更新工作(他们甚至似乎没有注册用户进入或离开服务器,所以我认为我缺乏一些权限)。经过大量搜索后,我在discord.py文档中找到,并在我的代码中添加了intents位,on_member_join、on_member_remove和on_member_update起作用,但on_message事件和所有命令都不起作用(我在on_message的开头添加了一个打印,但什么也没发生)。 经过一些调试,我发现阻止命令响应的代码似乎是
,intents=intents)
。但是,当删除此项时,不会触发on_member_join、on_member_remove和on_member_update(可以理解)


有什么建议吗?

我猜使用
intents=discord.intents()
会将所有intent设置为
False


您可以使用或。

我猜使用
intents=discord.intents()
会将所有意图设置为
False


您可以使用或。

它是
Intents.all()
而不是
Intents.all()
。后者不会像预期的那样工作,因为它是一个classmethod。它工作得很好,因为
intents
是存储
discord.intents()
的变量。我的示例在使用python 3.8时没有像预期的那样工作。我需要以另一种方式调用它,我注意到了这一点,因为它在源代码中被标记为clasmethod。您是否使用
Intents=discord.Intents()
而不是
Intents=discord.Intents()
?不……我熟悉Python。正如我指出的,您的代码是不正确的,不能按预期工作。它可能会运行和解释,但根据Discord API,它在位字段中无法按预期工作。总有一天我可能会发布一个完整的答案来证明这一点。它是
Intents.all()
,而不是
Intents.all()
。后者不会像预期的那样工作,因为它是一个classmethod。它工作得很好,因为
intents
是存储
discord.intents()
的变量。我的示例在使用python 3.8时没有像预期的那样工作。我需要以另一种方式调用它,我注意到了这一点,因为它在源代码中被标记为clasmethod。您是否使用
Intents=discord.Intents()
而不是
Intents=discord.Intents()
?不……我熟悉Python。正如我指出的,您的代码是不正确的,不能按预期工作。它可能会运行和解释,但根据Discord API,它在位字段中无法按预期工作。总有一天我会发布一个完整的答案来证明这一点。
from discord.ext import commands
from discord.ext import tasks
import random
import typing
from discord import Status
from discord import Activity, ActivityType
from discord import Member
from discord.ext.commands import Bot
from asyncio import sleep


intents = discord.Intents()
intents.members = True
intents.presences = True

print(discord.__version__)
bot = commands.Bot(command_prefix='!', intents =intents)

...
...

@bot.event
async def on_ready():
    print('hiii, We have logged in as {0.user}'.format(bot))
    await bot.change_presence(activity=discord.Game(name="Exploring the archives"))
bot.loop.create_task(status())

@bot.event
async def on_message(message):
    if message.author.id == BOT_ID:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('Hello Dad!')

    await bot.process_commands(message)

@bot.event
async def on_member_update(before,after):
    if before.status  != str(after) :
        print("{}, #{} has gone {} .".format(after.name,after.id,after.status))

@bot.event
async def on_member_remove(member):
    print(f'{member} has left a server.')

@bot.event
async def on_member_join(member):
    print(f'{member} has joined a server.')
    await member.send('Private message')

@bot.command(pass_context=True) 
async def summon(ctx):
       await ctx.send ("I have been summoned by the mighty {}, ".format(ctx.message.author.mention) + " bearer of {}. What is your command?".format(ctx.message.author.id))