我希望我的机器人在任何公会添加或删除时向特定公会频道发送消息。我如何在 Discord.py 中制作它?我知道 client.event 但我不确定如何使用它。
答案 0 :(得分:1)
我的机器人代码
@client.event
async def on_guild_join(guild):
for channel in guild.text_channels:
if channel.permissions_for(guild.me).send_messages:
embedHi = discord.Embed(
title="Thanks for adding me!",
description=
f"<:impostor:774673531786625024>I am the Impostor - a bot created by Baz!<:impostor:774673531786625024>\n\n<:noice:751384305464377375>You can join my support server by running $help and you can view all of my commands here as well!<:noice:751384305464377375>\n\n<:patreon:839897502925062165> Feel free to go to https://www.patreon.com/theimpostor to gain access to cool premium commands! <:patreon:839897502925062165>\nIf you join the <:purple:839879572631453696> Hacker Plan <:purple:839879572631453696>, then you will recieve all premium commands, a special role, early access to commands and even work in progress updates!\n:partying_face:Have fun!:partying_face:\n\n\n<:ping:757276110252670986>When you added this bot, it was in version {__version__}<:ping:757276110252670986>",
url="https://www.patreon.com/theimpostor",
colour=discord.Colour.red())
embedHi.set_thumbnail(
url=
"image url"
)
embedHi.set_image(url="image url")
embedHi.set_footer(
text="© Baz - The Impostor - Among Us bot for Discord")
await channel.send(embed=embedHi)
break
答案 1 :(得分:0)
@bot.event
async def on_guild_join(guild):
# send your message