【问题标题】:My on_member_join event is not working, i tried intents but it gives this error我的 on_member_join 事件不起作用,我尝试了意图,但它给出了这个错误
【发布时间】:2021-03-29 23:32:57
【问题描述】:

最近一次通话最后一次): 文件“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 行 等待 self.start(*args, **kwargs) 文件“/usr/local/lib/python3.8/site-packages/discord/client.py”,第 651 行,开始 等待self.connect(重新连接=重新连接) 文件“/usr/local/lib/python3.8/site-packages/discord/client.py”,第 586 行,在连接中 从 None 提高 PrivilegedIntentsRequired(exc.shard_id) 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

希望你能帮助我,我已经尝试了一切

【问题讨论】:

  • intents = discord.Intents.default() AttributeError: module 'discord' has no attribute 'Intents' 这就是我现在得到的错误
  • 我的 discord.py 版本也是 1.5.1
  • nvm 不用等待我没有 wtf thx 的帮助

标签: python pycharm discord discord.py discord.py-rewrite


【解决方案1】:

这个错误告诉你该怎么做。

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

【讨论】:

    猜你喜欢
    • 2020-11-08
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 2022-12-21
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多