我的 on_member_join 事件不工作,我尝试了 intents 但它给出了这个错误
My on_member_join event is not working, i tried intents but it gives this error
st 最近通话最后一次):
文件“randomgg.py”,第 1271 行,在 \u003cmodule\u003e 中
client.run(令牌)
文件“/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 行,在 运行ner
等待 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:分片 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
希望你能帮助我,我已经尝试了一切
该错误告诉您确切的操作。
- 转到https://discord.com/developers/applications
- 导航到您的应用程序
- 转到
Bot
部分
- 向下滚动并启用
SERVER MEMBER INTENT
st 最近通话最后一次): 文件“randomgg.py”,第 1271 行,在 \u003cmodule\u003e 中 client.run(令牌) 文件“/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 行,在 运行ner 等待 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:分片 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
希望你能帮助我,我已经尝试了一切
该错误告诉您确切的操作。
- 转到https://discord.com/developers/applications
- 导航到您的应用程序
- 转到
Bot
部分 - 向下滚动并启用
SERVER MEMBER INTENT