[Python] How to add the new / commands in discord and fix error

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm creating a discord bot to provide my paypal email and the amount, the idea was if I put /paypal amount: amount here it will make an embed with the information. And it worked.

    But I can't figure out how to add the new / commands thing and it also only listens to my commands when I mention the bot. Other than that it wont reply to the message.

    import discord
    from discord.ext import commands

    TOKEN = ''

    intents = discord.Intents.default()
    intents.typing = False
    intents.presences = False

    bot = commands.Bot(command_prefix='!', intents=intents)

    @bot.event
    async def on_ready():
    print(f'Bot is ready. Logged in as {bot.user.name}')

    @bot.command()
    async def paypal(ctx, amount: float):
    total_amount = amount + (amount * 0.2)
    embed = discord.Embed(title='Payment', color=discord.Color.blue())
    embed.add_field(name='Note', value='Send the amount to myemail@gmail.com as Friends and Family in USD (Do NOT add a note).', inline=True)
    embed.add_field(name='PayPal Email', value='My email', inline=False)
    embed.add_field(name='Amount', value=f'${total_amount}', inline=False)
    embed.set_thumbnail(url='https://www.paypalobjects.com/webstatic/mktg/logo/pp_cc_mark_37x23.jpg')

    await ctx.send(embed=embed)

    bot.run(TOKEN)


    I tried it but I couldn't do it - I would appreciate any help!

    Continue reading...

Compartilhe esta Página