0

When I use an 'or' in my if statement it takes what's in the bottom if statement

@client.command()
async def png(ctx, *, arg):
    if(arg == 'mixbox' or 'item box'):
        await ctx.send(file=discord.File('mixbox.png'))
    elif(arg == 'pack'):
        await ctx.send(file=discord.File('pack.png'))

when I type !png item box it gives a png of an item box. when I type !png pack it still give the same png item box.

but if I change the code to this:

@client.command()
async def png(ctx, *, arg):
    if(arg == 'mixbox'):
        await ctx.send(file=discord.File('mixbox.png'))
    elif(arg == 'item box'):
        await ctx.send(file=discord.File('mixbox.png'))
    elif(arg == 'pack'):
        await ctx.send(file=discord.File('pack.png'))

it works fine. Do I just do it this way or is there a way to make it work? (I'm a beginner so there might be a simple answer that I don't know)

  • 1
    `or` does not work that way. you're looking for `arg == 'mixbox' or arg == 'item box'` – Aaron Feb 11 '21 at 02:10

1 Answers1

0

When using the or operator, you need to specify it for both conditions. Here you go, this should work:

@client.command()
async def png(ctx, *, arg):
    if(arg == 'mixbox' or arg == 'item box'):
        await ctx.send(file=discord.File('mixbox.png'))
    elif(arg == 'pack'):
        await ctx.send(file=discord.File('pack.png'))
Aditya Tomar
  • 1,601
  • 2
  • 6
  • 25