'How do I make a specific command with a insertable value with Python? Discord bot

I would like to have a command that has the availability of this:

>paypal 5

Bot's message: Please send $5 to this email:

Anyone able to help me out with this? Thank you!



Solution 1:[1]

I am guessing you mean arguments by "insertable" values.

You can add arguments like this:

@bot.command(pass_context=True)
async def paypal(ctx, cash): # cash being the argument
    await ctx.send(f'Please send {cash}$ to this email:')

Solution 2:[2]

In a function wrapped by @bot.command decorator, you can pass arguments with type hints casting types, and also using * operator:

@bot.command()
async def paypal(ctx, cash: int):
    await ctx.send(f'Please send {cash}$ to this email: ')

This command can be invoked in Discord this way:

>paypal 15
Please send 15$ to this email: 

Assuming > is your bot's prefix.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 parsel
Solution 2 FLAK-ZOSO