英文:
Hello, I'm making an avatar command. I want the embed to appear and write that the user does not have an avatar. But it doesn't work
问题
`@commands.command(aliases=['ava', 'аватарка'])
async def avatar(self, ctx, *, member: discord.Member = None):
if not member:
member = ctx.message.author
userAvatar = member.avatar
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {member}')
embed.set_image(url=member.avatar)
embed.set_footer(text=f'Выполнено {ctx.author}', icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
if member:
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {member}')
embed.set_image(url=member.avatar)
embed.set_footer(text=f'Выполнено {ctx.author}', icon_url=ctx.author.avatar)
await ctx.send(embed=embed)`
英文:
` @commands.command(aliases=['ava', 'аватарка'])
async def avatar(self, ctx, *, member: discord.Member = None):
if not member:
member = ctx.message.author
userAvatar = member.avatar
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {member}')
embed.set_image(url=member.avatar)
embed.set_footer(text=f'Выполнено {ctx.author}', icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
if member:
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {member}')
embed.set_image(url=member.avatar)
embed.set_footer(text=f'Выполнено {ctx.author}', icon_url=ctx.author.avatar)
await ctx.send(embed=embed)`
答案1
得分: 1
I don't really understand what you need that member check for.. because everyone who can use a command is already a member on your discord or am I wrong? Maybe this will work for you?:
@commands.command(aliases=['ava', 'аватарка'])
async def avatar(self, ctx):
author = ctx.message.author
if author.avatar is None:
await ctx.send('The author has no avatar!')
else:
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {author.name}')
embed.set_image(url=author.avatar)
embed.set_footer(text=f'Выполнено {author.name}', icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
英文:
I don't really understand what you need that member check for.. because everyone who can use a command is already a member on your discord or am I wrong? Maybe this will work for you?:
@commands.command(aliases=['ava', 'аватарка'])
async def avatar(self, ctx):
author = ctx.message.author
if author.avatar is None:
await ctx.send('The author has no avatar!')
else:
embed = discord.Embed(color=discord.Color.darker_grey(), timestamp=ctx.message.created_at)
embed.set_author(name=f'Аватар {author.name}')
embed.set_image(url=author.avatar)
embed.set_footer(text=f'Выполнено {author.name}',icon_url=ctx.author.avatar)
await ctx.send(embed=embed)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论