Skip to content Skip to sidebar Skip to footer

How Do I Make This Command Only Work In Multiple Channels Using Discord.py

i am trying to make a command work in 2 trade channels as it is for checking peoples vouches to see if they are trustworthy. my current code doesn't work but here it is @client.com

Solution 1:

First of all - you have to first check the channels. In the comments you mentioned you don't pass a member as an argument when testing, meaning that that part of the code is never reached as member is always None so it gets into the first if.

@client.command()asyncdefvouches(ctx, member : discord.User=None):
    allowed_channels = [813832766248583199, 813832801220689931]

    # Check channels FIRSTif ctx.channel.idnotin allowed_channels:
        returnawait ctx.send("You can't vouch in this channel")

Also, None-checks should be done using is, not ==.

elif member isNone:
        ...

PS. This isn't wrong, but using elif is unnecessary if the if-statements above use returns. In case one of the above if/elif's was entered, the function returns, so there's no way to reach the elif's below anyways.

Lastly, the code for member is None and members is not None is the exact same using a different userid, consider just creating a variable with the id or creating a function instead of duplicating that block of code.

Post a Comment for "How Do I Make This Command Only Work In Multiple Channels Using Discord.py"