#๐Ÿ”’ Creating a choice however the choice are not showing?

7 messages ยท Page 1 of 1 (latest)

toxic birch
#
@bot.tree.command(name="setup", description="Set up the allowed channel for the bot.")
@app_commands.describe(action="Choose to add or remove a channel.", channel="The channel to add or remove.")
async def setup(interaction: discord.Interaction, action: str, channel: TextChannel = None) -> None:
    if not interaction.user.guild_permissions.administrator:
        embed = discord.Embed(
            title="Permission Denied",
            description="You do not have permission to use this command.",
            color=discord.Color.red()
        )
        try: await interaction.response.send_message(embed=embed, ephemeral=True)
        except: pass
        return

    if action == "add":
        if channel:
            allowed_channel_ids[interaction.guild.id] = channel.id
            save_allowed_channel(interaction.guild.id, channel.id)
            response = f"Allowed channel for this server set to {channel.mention}."
        else:
            response = "Please specify a channel to add."
    elif action == "remove":
        if interaction.guild.id in allowed_channel_ids:
            del allowed_channel_ids[interaction.guild.id]
            save_allowed_channel(interaction.guild.id, None) 
            response = "Allowed channel for this server has been removed."
        else:
            response = "No channel is currently set for this server."
    else:
        response = "Invalid action. Use 'add' or 'remove'."

    try: await interaction.response.send_message(response)
    except: pass```
alpine lintelBOT
#

@toxic birch

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.

toxic birch
#

Anticipating to have like this

#

nvm i got it :)

#

!close

alpine lintelBOT
#
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.