简体   繁体   English

Discord.py on_member_join 事件

[英]Discord.py on_member_join event

I need help with my code, i wanted to make my bot sends a message on the first channel from the top when a particular member joins, but i got error with if member.id == *id*我的代码需要帮助,我想让我的机器人在特定成员加入时在顶部的第一个频道上发送消息,但是if member.id == *id*我出错了

@bot.event
async def on_member_join(member):
    if member.id == *my id here, i just dont want to show it*
        await message.channel.send('Nice guy joined the server!')
@bot.event
async def on_member_join(member):
    if member.id == 660959014691143691:
        await member.guild.text_channels[0].send('Nice guy joined the server!')

You haven't defined the message so you can't use message.channel.send .您尚未定义message ,因此无法使用message.channel.send If you just want to send the first channel of the guild, that's simple to do with guild.text_channels .如果您只想发送公会的第一个频道,使用guild.text_channels很简单。

@bot.event
async def on_member_join(member):
    if member.id == *my id here, i just dont want to show it*
        await member.guild.text_channels[0].send('Nice guy joined the server!')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM