#๐Ÿ”’ help with slash comms discord.py

12 messages ยท Page 1 of 1 (latest)

blazing fox
#
@client.tree.command(name="deposit", description="Deposit your wallet into your bank!")
@app_commands.describe(amountdep="How much would you like to deposit?")
async def deposit(interaction: discord.Interaction, amountdep : str):
    with open("purse.json", "r") as f:
        data = json.load(f)

    if str(interaction.user.id) not in data:
        data[str(interaction.user.id)] = {"wallet": 20, "bank": 0}

    wallet = data[str(interaction.user.id)]["wallet"]
    bank = data[str(interaction.user.id)]["bank"]

    if amountdep > wallet:
        await interaction.response.send_message("You don't have that much to deposit!", ephemeral=True)
    else:
        data[str(interaction.user.id)]["wallet"] = wallet - amountdep
        data[str(interaction.user.id)]["bank"] = bank + amountdep

        embed = discord.Embed(
            title=f"{interaction.user.name}'s new balance",
            color=discord.Color.blue()
        )
        embed.add_field(name =f"Wallet", value = wallet)
        embed.add_field(name =f"Bank", value = bank)
        await interaction.response.send_message(embed=embed, ephemeral=True)

this command just doesnt show up in my bot's command list
any help?

shut nicheBOT
#

@blazing fox

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pastel coyote
blazing fox
#
@client.event
async def on_ready():
    await client.tree.sync()
    print(f'Logged in as {client.user}!')
pastel coyote
#

seems fine enough, can you try reloading your desktop client with Ctrl+R?

blazing fox
#

do itry it on my discord?

pastel coyote
#

like your actual discord app on your computer

#

there's a long-standing issue discord has with not showing new commands until after a restart/reload

blazing fox
#

oh yeah now it worked

#

alright thank you

shut nicheBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.