#Member as an optional param with Slash commands

1 messages · Page 1 of 1 (latest)

glacial sage
#
@discord.slash_command(guild_ids=config['main_guilds'],description="Gets a user's avatar")
    async def avatar(self, ctx, member: discord.Option(discord.Member)=None):
        if member is None:
            member = ctx.author
        embed = discord.Embed(title="T", description=f"{member.id}", color=0)
        embed.set_footer(text=randomMsg())
        await ctx.respond(embed=embed)
#

In my head, this should require a type of "Member" to be passed (via mentioning the user I assume?). I've used =None before so I figured if I check it and redefine the value of member then it would work in returning a member ID?

paper dagger
#

I didn't understand your question

#

Are you saying that if member option is not passed and you assign ctx.author to member then would member.id still work?

#

Then yes it will work