我是用 python 制作不和谐机器人的新手,我想制作一个在有人加入服务器时显示欢迎消息的事件。
我尝试使用此代码
import discord
import random
from discord.ext import commands
alfred = commands.Bot(command_prefix = '!', description = "Hey!, I'm Alfred, How can I assist you?")
#EVENT
@alfred.event
async def on_ready():
print("I'm Alfred and I'm Online!")
@alfred.event
async def on_member_join(member):
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
await message.channel.send(embed=embed)
但是没有用,甚至discord的文档都说该事件是“on_member_join”。
我真的希望你能帮助我:)
答案 0 :(得分:0)
试试这个,只需将 790274325533378682
替换为您的频道 ID
@alfred.event
async def on_member_join(member):
channel = alfred.get_channel(790274325533378682)
embed=discord.Embed(title="Welcome!",description=f"{member.mention} Just Joined")
await channel.send(embed=embed)