#๐ how to accept parts of msg as parameter
38 messages ยท Page 1 of 1 (latest)
@raw narwhal
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.
is this for a discord bot?
yes
can u send a snippet of code of what u have so far is it using discord.py?
umm like for this??
yes it uses discord.py
yeah
nothing
oh ok lol
i couldnt figure out how to take multiple things
so u jut want to have it take multiple paramters right
yes
u can use slash commands to make it easier
okay
but still how can i do this with prefix
because like
idk maybe its jus me
i prefer prefix ๐ญ
hol on ill send u an example
okay
๐ญ
well
if you can
pls jus send that / command thing
so i can get refference uk
sure np
this was part of a trivia bot i used to work on
@tree.command(
name='trivia',
description='Play some trivia',
guild=discord.Object(id=--------))
@app_commands.describe(category='Select a category')
@app_commands.choices(category=[
app_commands.Choice(name='Random', value='random'),
app_commands.Choice(name='Animals', value='animals'),
app_commands.Choice(name='Art & Literature', value='art & literature'),
app_commands.Choice(name='Celebrities', value='celebrities'),
app_commands.Choice(name='Entertainment', value='entertainment'),
app_commands.Choice(name='Food', value='food'),
app_commands.Choice(name='Geography', value='geography'),
app_commands.Choice(name='History', value='history'),
app_commands.Choice(name='Science', value='science'),
app_commands.Choice(name='Sports', value='sports'),
app_commands.Choice(name='Technology', value='technology'),
app_commands.Choice(name='Video Games', value='video games')
])
so this basically gives u a list of things to choose from ill also find soemthing that gives u an input field of other sorts
and i had this in the begining
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='$', intents=intents)
client = discord.Client(intents=intents)
tree = app_commands.CommandTree(client)
alr here so this is what a function that takes in a text value and a list of choices would look like
@tree.command(
name='trivia',
description='Play some trivia',
guild=discord.Object(id=----)
)
@app_commands.describe(
category='Select a category',
difficulty='Choose a difficulty (easy, medium, hard)'
)
@app_commands.choices(category=[
app_commands.Choice(name='Random', value='random'),
app_commands.Choice(name='Animals', value='animals'),
app_commands.Choice(name='Art & Literature', value='art & literature'),
app_commands.Choice(name='Celebrities', value='celebrities'),
app_commands.Choice(name='Entertainment', value='entertainment'),
app_commands.Choice(name='Food', value='food'),
app_commands.Choice(name='Geography', value='geography'),
app_commands.Choice(name='History', value='history'),
app_commands.Choice(name='Science', value='science'),
app_commands.Choice(name='Sports', value='sports'),
app_commands.Choice(name='Technology', value='technology'),
app_commands.Choice(name='Video Games', value='video games')
])
async def trivia(
interaction: discord.Interaction,
category: app_commands.Choice[str],
difficulty: str
):
so like category = "select a category" and describe correspond to the trivia's input paramaters
hope this helps
This help channel has been closed. 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.