我的 on_member_join 事件不起作用。我尝试了意图,但它给出了这个错误

use*_*264 10 python pycharm discord discord.py

考虑:

st 最近的调用最后):
文件“randomgg.py”,第 1271 行,在 \u003cmodule\u003e
client.run(token)
文件“/usr/local/lib/python3.8/site-packages/discord/client.py” ,第 708 行,运行中
return future.result()
文件“/usr/local/lib/python3.8/site-packages/discord/client.py”,第 687 行,在运行程序中
等待 self.start(*args, * *kwargs)
文件“/usr/local/lib/python3.8/site-packages/discord/client.py”,第651行,在开始
等待self.connect(reconnect=reconnect)
文件“/usr/local/lib/ python3.8/site-packages/discord/client.py”,第 586 行,在 connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
Discord.errors.PrivilegedIntentsRequired: Shard ID None 正在请求尚未在开发者门户。建议访问https://discord.com/developers/applications/并在应用程序页面中显式启用特权意图。如果这是不可能的,那么请考虑禁用特权意图。\

我的代码是

import aiohttp
import discord
import asyncio
from collections import Counter
import typing
from discord.ext import commands
import os
from discord.ext.commands import has_permissions
import random
import json
from discord import Status
from asyncio import gather
from discord.utils import get
import datetime
from discord.utils import get
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='.', intents=intents)
client.remove_command('help')

def check_if_it_is_me(ctx):
    return ctx.message.author.id == 465946367622381578

@client.event
async def status_task():
    while True:
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('status1'))
        await asyncio.sleep(4)
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('status2'))
        await asyncio.sleep(4)
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('status3'))
        await asyncio.sleep(4)

@client.event
async def on_ready():
    print(f'{client.user.name} is ready')
    client.loop.create_task(status_task())

@client.event
async def on_member_join(member):
    mem_join = member.joined_at
    guild_create = member.created_at
    join_days = (mem_join - guild_create).days
    role = discord.utils.get(member.guild.roles, id=714805001918349344)
    channel = discord.utils.get(member.guild.channels, id=771081754038501376)
    if join_days < 10:
        await channel.send(f'{role.mention} {member} is suspicious of being an alt, he joined {join_days} after creating his account. Pls keep an eye on him')

@client.event
async def on_member_remove(member):
    pass
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

Łuk*_*ski 24

该错误确切地告诉您该怎么做。

  1. 转到https://discord.com/developers/applications
  2. 导航至您的应用程序
  3. 转到该Bot部分
  4. 向下滚动并启用SERVER MEMBERS INTENT