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

huangapple go评论95阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2023年3月8日 16:08:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670611.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定