#๐ Does anyone know what this thing called?
8 messages ยท Page 1 of 1 (latest)
@lethal light
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.
Closes after a period of inactivity, or when you send !close.
@bot.tree.command(name="setup", description="Set up the allowed channel for the bot.")
@app_commands.describe(option="Choose whether to add or remove a channel.", channel="The channel to add or remove.")
async def setup(interaction: discord.Interaction, option: str , channel: TextChannel) -> 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()
)
await interaction.response.send_message(embed=embed, ephemeral=True)
return
if option == "add":
if interaction.guild.id not in allowed_channel_ids:
allowed_channel_ids[interaction.guild.id] = []
allowed_channel_ids[interaction.guild.id].append(channel.id)
save_allowed_channel(interaction.guild.id, channel.id) # Save to DB
await interaction.response.send_message(f"Allowed channel for this server added: {channel.mention}", ephemeral=True)
elif option == "remove":
if interaction.guild.id in allowed_channel_ids and channel.id in allowed_channel_ids[interaction.guild.id]:
allowed_channel_ids[interaction.guild.id].remove(channel.id)
remove_allowed_channel(interaction.guild.id, channel.id) # Remove from DB
await interaction.response.send_message(f"Allowed channel for this server removed: {channel.mention}", ephemeral=True)
else:
await interaction.response.send_message(f"Channel {channel.mention} is not in the allowed list.", ephemeral=True)
else:
await interaction.response.send_message("Invalid option. Use 'add' or 'remove'.", ephemeral=True)```
@lethal light its called Choices
where it can have a list of Choices where a string matches to a value
the string showing in discord and the value getting passed into the function
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.