D
D
DeDabby2021-09-27 07:59:22
Python
DeDabby, 2021-09-27 07:59:22

The bot does not see spaces, what should I do?

I am writing an economic bot. The problem is that when I write -buy (something), if there are two words in the subject in the name, then the code does not react, it does not see. How to fix?

mainshop = [{"name":"Морской конек","price":1000,"description":"*******"},] - магазин 

@client.command()
async def buy(ctx,item,amount = 1):
    await open_account(ctx.author)

    res = await buy_this(ctx.author,item,amount)

    if not res[0]:
        if res[1]==1:
            await ctx.send("Этого нет в магазине")
            return
        if res[1]==2:
            await ctx.send(f"У вас нет столько  Коинов {amount} {item}")
            return


    await ctx.send(f"Вы купили {amount} {item}")  - код отвечающий за покупку

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Nevzorov, 2021-09-27
@DeDabby

https://discordpy.readthedocs.io/en/stable/ext/com...

from typing import Optional

...

@client.command()
async def buy(ctx, amount: Optional[int] = 1,  *, item: str):

S
soremix, 2021-09-27
@SoreMix

For example, wrap the phrase in quotation marks

P
ProToType, 2021-09-27
@ProToType

It's a common thing, you just need to add * before item toy async def buy(ctx, *, item, amount = 1):

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question