我正在尝试构建一个Discord机器人,该机器人在用户加入服务器时显示有关用户的信息,这是我的代码:
import discord
import datetime
e = datetime.datetime.now()#Get the current date and time
client = discord.Client()
join = client.get_channel(channel)#Channel to send the embed
@client.event
async def on_ready():
await client.change_presence(status = discord.Status.online, activity = discord.Game('auf MarkusGameTech.tk'))
print('Eingeloggt als {0.user}'.format(client))
print('um',e.strftime("%H:%M:%S"))
@client.event
async def on_member_join(member):
embed = discord.Embed(title="Willkommen auf dem Server", color=0x0064ff) #Start of embed
embed.set_author(name=f'{member}')
embed.set_thumbnail(url='user.avatar_url')
embed.add_field(name='Beigetreten am:', value=e.strftime("%d.%m%.y %H:%M"), inline=False)
embed.add_field(name='Erstellt am:', value=member.created_at.strftime("%d.%m.%Y um %H:%M"), inline=False)
embed.set_footer(text='MarkusGameTech')
await join.send(embed=embed) #Prints embed
client.run('token')
嵌入内容应如下所示:https://pasteboard.co/IMpzoks.png
抱歉,如果我提供的信息太少