discord.py的on_member_join函数未被调用?

huangapple go评论60阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月18日 08:47:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708894.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定