So I want to make a command where for only a few certain people it says something specific and for the others that aren't specified on the code, it will just say a normal thing.
@client.command()
async def test(ctx):
if ctx.author.id == 1:
await ctx.reply('Hello Person 1')
if ctx.author.id == 2:
await ctx.reply("Hello Person 2")
if not ctx.author.id == 1 and 2:
await ctx.reply ("Hello")
Something like the code above, which I did in fact try, but it will not count the second condition on line 7. Anyone have a solution?
ctx.author.id == 1 and 2
This is True
if ctx.author.id == 1
and 2
. Since 2
is not 0
and thus always truthy, the entire expression is always True
if ctx.author.id == 1
The not
then reverses that, so the entire expression as you used it is always True
if ctx.author.id != 1
What you meant was:
not (ctx.author.id == 1 or ctx.author.id == 2)
Or:
ctx.author.id != 1 and ctx.author.id != 2
Or:
ctx.author.id not in [1, 2]
Even this does not work:
not ctx.author.id == (1 and 2)
Because that just computes 1 and 2
(neither is 0
, so the result is a truthy 2
). Not what you are after, since that just ends up testing if ctx.author.id
equals 2 (confusingly).