【发布时间】:2021-04-05 09:49:40
【问题描述】:
我正在尝试触发 on_member_join 事件,但当有人加入时它不会触发。我也试图在加入时给某人一个角色,但我几乎知道如何做到这一点。我只是不明白为什么这个事件没有在加入时触发。它正在工作,但它停止了。
bot = commands.Bot(command_prefix="!")
player = {}
# Events
@bot.event
async def on_ready():
print("Bloody Admin is online:")
await bot.change_presence(status=discord.Status.online, activity=discord.Game("Prefix: !"))
@bot.event
async def on_member_join(member):
print("Joined")
@bot.event
async def on_member_remove(member):
await member.create_dm()
await member.send("I guess I watched you too hard, sorry to see you leave :(")
@bot.event
async def on_command_error(ctx, error):
await ctx.send(error)
我什至尝试将其更改为客户端事件
bot = commands.Bot(command_prefix="!")
client = discord.Client()
player = {}
# Events
@bot.event
async def on_ready():
print("Bloody Admin is online:")
await bot.change_presence(status=discord.Status.online, activity=discord.Game("Prefix: !"))
@client.event
async def on_member_join(member):
print("Joined")
@client.event
async def on_member_remove(member):
await member.create_dm()
await member.send("I guess I watched you too hard, sorry to see you leave :(")
@bot.event
async def on_command_error(ctx, error):
await ctx.send(error)
任何帮助都会很棒。谢谢。
【问题讨论】:
-
你有这个意图吗?
标签: python discord discord.py