英文:
discord.py on_member_join function not being called?
问题
I am trying to use on_member_join to set a default role in my server but the on_member_join function is never being called and I'm not quite sure why.
我尝试使用on_member_join来设置服务器的默认角色,但on_member_join函数从未被调用过,我不太确定为什么。
I have the "Privileged Gateway Intents" and all the imports.
我已经启用了“特权网关意图”并导入了所有必要的内容。
import discord
from discord import app_commands
from discord.ext import commands
import responses #my other class with the text responses
def run_discord_bot():
TOKEN = 'token here'
intents = discord.Intents.default()
intents.message_content = True
discord.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'{client.user} is now running!')
@client.event
async def on_member_join(member):
print('here') #never being printed
client.run(TOKEN)
I looked at other similar questions and they all said to check the "Privileged Gateway Intents" which I did, and they are all on.
我查看了其他类似的问题,他们都建议检查“特权网关意图”,我已经检查了,并且都已启用。
Discord Dev Intents Screenshot
I also have on_message set up, and it is working. Tried resetting the privileges of the bot in dev and reinviting it, but to no avail. No error is ever sent either. Console is clean, which is how I know it is never even running in the first place.
我还设置了on_message,它也正常工作。尝试在开发中重置机器人的权限并重新邀请它,但都没有成功。也没有收到任何错误。控制台干净,这就是我知道它从未运行的原因。
英文:
I am trying to use on_member_join to set a default role in my server but the on_member_join function is never being called and I'm not quite sure why.
I have the "Privileged Gateway Intents" and all the imports
import discord
from discord import app_commands
from discord.ext import commands
import responses #my other class with the text responses
def run_discord_bot():
TOKEN = 'token here'
intents = discord.Intents.default()
intents.message_content = True
discord.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'{client.user} is now running!')
@client.event
async def on_member_join(member):
print('here') #never being printed
client.run(TOKEN)
I looked at other similar questions and they all said to check the "Privileged Gateway Intents" which I did and they are all on
Discord Dev Intents Screenshot
I also have on_message set up and it is working.
Tried resetting the privs of the bot in dev and reinviting it but to no avail.
No error is ever sent either. Console is clean which is how I know it is never even running in the first place.
Not sure what to check or where to go after this.
答案1
得分: 0
你可以尝试两件事。将discords.members = true
更改为intents.members = true
,如果还不行,请将您的意图更改为intents = discord.Intents.all()
,尽管我认为这对您的情况可能不是必要的。
英文:
You can try two things. Change the discords.members = true
into intents.members = true
and if not that change your intents to do intents = discord.Intents.all()
, although I do not think this is necessary for your case.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论