即使该bot在服务器中并且在线,discord.py on_member_join也不起作用 [英] discord.py on_member_join not working even though the bot is in the server and online
本文介绍了即使该bot在服务器中并且在线,discord.py on_member_join也不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图制造一个不和谐的机器人,但是我遇到了 on_member_join
函数的问题.该机器人已获得管理员权限,控制台中也不会出现错误
I have been trying to make a discord bot but I am facing problems with the on_member_join
function. The bot has been given admin permissions and I face no error in the console either
这是代码
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client()
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_member_join(member):
await member.send('welcome !')
client.run('TOKEN')
推荐答案
您需要在Client()初始化程序中传递意图
You need to pass intents in the Client() initializer
下面是修改后的代码:
import discord
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_member_join(member):
await member.send('welcome !')
client.run('TOKEN')
这篇关于即使该bot在服务器中并且在线,discord.py on_member_join也不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文