Python 当bot加入服务器时发送消息[Discord.py]
我目前正在制作一个discord bot,并希望在服务器加入时在服务器的Python 当bot加入服务器时发送消息[Discord.py],python,discord.py,Python,Discord.py,我目前正在制作一个discord bot,并希望在服务器加入时在服务器的#general通道中发送一条消息,这是我到目前为止的代码 async def on_guild_join(guild): general = find(lambda x: x.name == 'general', guild.text_channels) if general and general.permissions_for(guild.me).send_messages: embe
#general
通道中发送一条消息,这是我到目前为止的代码
async def on_guild_join(guild):
general = find(lambda x: x.name == 'general', guild.text_channels)
if general and general.permissions_for(guild.me).send_messages:
embed=discord.Embed(title="**======== *Thanks For Adding Me!* ========**", description=f"""
Thanks for adding me to {guild.name}!
You can use the `--help` command to get started!
""", color=0xd89522)
await general.send(embed=embed)
当我运行这段代码时,什么都不会发生。我没有得到任何ERORR或输出
如果有人能帮忙,那就太棒了。谢谢 你加入工会的
是否有?当我用这个decorator测试代码时,它工作得很好
此外,如果你的机器人加入的公会没有名为“general”的频道,你可能需要一个后备通道。在guild.text\u频道[0]
中发送消息可能更可靠,它将在第一个频道中发送消息,或者在guild.system\u频道
中发送消息