我的 on_member_join 事件不起作用,我尝试了意图,但它给出了这个错误 [英] My on_member_join event is not working, i tried intents but it gives this error

查看:165
本文介绍了我的 on_member_join 事件不起作用,我尝试了意图,但它给出了这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近一次通话):文件randomgg.py",第 1271 行,位于 \u003cmodule\u003e客户端运行(令牌)运行中的文件/usr/local/lib/python3.8/site-packages/discord/client.py",第 708 行返回 future.result()文件/usr/local/lib/python3.8/site-packages/discord/client.py",第687行,在runner等待 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行,连接从无提高 PrivilegedIntentsRequired(exc.shard_id)discord.errors.PrivilegedIntentsRequired:Shard ID None 正在请求尚未在开发人员门户中明确启用的特权意图.建议去https://discord.com/developers/applications/ 并明确启用应用程序页面中的特权意图.如果这是不可能的,那么请考虑禁用特权意图.

st recent call last): File "randomgg.py", line 1271, in \u003cmodule\u003e client.run(token) File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 708, in run return future.result() File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 687, in runner await self.start(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 651, in start await self.connect(reconnect=reconnect) File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 586, in connect raise PrivilegedIntentsRequired(exc.shard_id) from None discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.

我的代码是

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

希望你能帮助我我也尝试了一切

hope u can help me i alr tried everything

推荐答案

该错误会准确地告诉您该怎么做.

The error tells you exactly what to do.

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

这篇关于我的 on_member_join 事件不起作用,我尝试了意图,但它给出了这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆