0

I've created a bot that when commanded with ?give {arg}, will output {arg} has been given!. However, I've added some specific foods that will output a different message (eg. ramen will output an image of ramen), but, because it's still technically an arg, the bot outputs both messages, how do I code it so that if the arg is one of the specific foods, the bot will only output that specific message?

my code currently:

@client.command()
async def give(ctx, arg, member: discord.Member = None, case_insensitive=True):
    if arg == 'lumpia':
        if member:
            username = ctx.message.author.display_name
            name = member.display_name
            embed = discord.Embed(title=(f'{username} has given lumpia to {name}!'), description =('{|__|}\n( • . •)\n/ >' ), color=0x83B5E3)
            embed.set_image(url='https://images.summitmedia-digital.com/yummyph/images/2019/10/26/porkandshrimplumpiarecipe2.jpg')

        else:
            embed = discord.Embed(title=('Lumpia has been given!'), description=('{|__|}\n( • . •)\n/ >' ), color=0x83B5E3)
            embed.set_image(url = 'https://images.summitmedia-digital.com/yummyph/images/2019/10/26/porkandshrimplumpiarecipe2.jpg')
        await ctx.send(embed=embed)
    if arg == 'ramen':
        if member:
            username = ctx.message.author.display_name
            name = member.display_name
            embed = discord.Embed(title=(f'{username} has given a bowl of ramen to {name}!'), description=('{|__|}\n( • . •)\n/ >'), color=0x83B5E3)
            embed.set_image(url ='https://www.theflavorbender.com/wp-content/uploads/2019/01/Easy-Chicken-Ramen-Featured-500x375.jpg')
        else:
            embed = discord.Embed(title=(f'a bowel of ramen has been given!'), description=('{|__|}\n( • . •)\n/ >'), color=0x83B5E3)
            embed.set_image(url ='https://www.theflavorbender.com/wp-content/uploads/2019/01/Easy-Chicken-Ramen-Featured-500x375.jpg')
        await ctx.send(embed=embed)
    if arg != 'ramen' or 'prawn' or 'lumpia'or 'bubble-tea' or 'fish' or 'prawn' or 'iced-coffee' or 'americano' or 'latte' or 'ice-cream' or 'cheescake' or 'fast-food-meal' or 'burger' or 'fries' or 'ramen':
        if member:
            username = ctx.message.author.display_name
            name = member.display_name
            embed = discord.Embed(title=(f'{username} has given (a) {arg} to {name}!'), description='uwu', color=0x83B5E3)
        else:
            embed = discord.Embed(title=(f'(A) {arg} has been given!'), description='uwu', color=0x83B5E3)

    await ctx.send(embed=embed)
Amy sdj
  • 47
  • 7
  • Does this answer your question? [Comparing a string to multiple items in Python](https://stackoverflow.com/questions/6838238/comparing-a-string-to-multiple-items-in-python) – GPhilo Jul 21 '20 at 11:21
  • `arg != 'ramen' or 'prawn'` means `If arg is different than "ramen" or the string "prawn" is not empty` (and 'prawn' is always not empty). Look in the linked question above how comparisons with multiple strings are done correctly – GPhilo Jul 21 '20 at 11:22

1 Answers1

2

You can use an if/elif chain so that the evaluation starts at the first match:

if arg == 'lumpia':
    # do something
elif arg == 'ramen':
    # do something
else:
    # general case
Aplet123
  • 33,825
  • 1
  • 29
  • 55