我一直试图在discord.py (重写)中加入加入消息。 我得到一个错误。首先,我的命令在下面。
@bot.event
async def on_member_join(member):
guild = member.guild
channel = (553090886683197451)
message ='Hello {}, Welcome to {} Discord server, We hope u good day at our server. Also please read the rules carefully'.format(member.mention, guild.name)
await user.send(channel, message)
错误在下面
line 15, in on_member_join
await user.send(channel, message)
NameError: name 'user' is not defined
我希望我的机器人将消息发送到特定的渠道,以及我在上面编写的消息。任何人都可以帮忙,那就太好了!。
答案 0 :(得分:3)
与异步版本不同,您必须首先使用get_channel()
方法找到频道
@bot.event
async def on_member_join(member):
channel = bot.get_channel(553090886683197451)
guild=member.guild
message ='Hello {}, Welcome to {} Discord server, We hope u good day at our server. Also please read the rules carefully'.format(member.mention, guild.name)
await channel.send(message)
正如Patric Haugh所说,您会member.send()
对私人消息进行