我试图制造一个不和谐的机器人,打印用户加入或离开到控制台。然而,它似乎并没有触发我的机器人。这是我的密码:
这是我目前的代码
import discord
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.event
async def on_ready():
print("Bot is ready")
@client.event
async def on_member_join():
print("{member} hat den Server betreten.")
```@client.event
async def on_member_remove():
print("{member} hat den Server verlassen.")
client.run('My Token')有人能帮帮我吗?
发布于 2021-02-19 10:09:50
使用on_member_join或其他与成员事件相关的事件必须要求启用成员意图。这样可以让这些事件运行,因为它们是私有的,应该小心使用。
意图可以从不和谐的开发人员门户启用,从那里您只需要确保您已经启用了意图在意图"Bot“类别。然后,您需要在定义bot或客户端的部分中定义和使用bot代码中的意图:
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='your bot prefix', intents=intents)https://stackoverflow.com/questions/66275516
复制相似问题