#๐Ÿ”’ Code is unreachable??

10 messages ยท Page 1 of 1 (latest)

royal mural
#

i do not understand

wanton elbowBOT
#

@royal mural

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

royal mural
#

why is it not reachable

#
@selfie.command()
async def remove(ctx: commands.Context, member: discord.Member = None):
    if not member:
        await ctx.send("![error](https://cdn.discordapp.com/emojis/1115150970104590437.webp?size=128 "error") **Please mention a user to remove the role from**")
        return 

    if not any(role.id == STAFF_ROLE_ID for role in ctx.author.roles):
        await ctx.send("![error](https://cdn.discordapp.com/emojis/1115150970104590437.webp?size=128 "error") **You do not have permission to use this command**")
        return

    selfie_role = ctx.guild.get_role(VERIFIED_ROLE_ID)
    if selfie_role in member.roles:
        await member.remove_roles(selfie_role)
        await ctx.send(f"![check](https://cdn.discordapp.com/emojis/1127352286952300584.webp?size=128 "check") **Verified role removed from {member.mention}**")
    else:
        await ctx.send(f"![error](https://cdn.discordapp.com/emojis/1115150970104590437.webp?size=128 "error") {member.mention} **doesn't have the Selfie role**")```
cedar rampart
#

btw your annotation is invalid, as None is not a discord.Member

#

try member: discord.Member | None

wild haven
#

Does it mark it reachable if you do if member is None: ?

dreamy crane
#

presumably a discord.Member is always truthy

wanton elbowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.