#๐ https://paste.pythondiscord.com/YH5Q
17 messages ยท Page 1 of 1 (latest)
@sick shell
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.
I am trying to make it so when someone click on one of those choices and enters it the bot will give a different response for each option
https://paste.pythondiscord.com/YH5Q
Can someone help me
does it not work?
try this
import discord
from discord.app_commands import Option, Command
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.event
async def on_ready():
print('Bot is online')
try:
synced = await bot.sync_commands()
print(f"Synced {len(synced)} command(s)")
except Exception as e:
print(e)
@bot.slash_command(
name='host',
description='Host a mg/lg/game night',
options=[
Option(
type_=discord.ApplicationCommandOptionType.INTEGER,
name='game',
description='Games to choose from',
choices=[
discord.app_commands.Choice(name='Mag Game', value=1),
discord.app_commands.Choice(name='Lob Game', value=2),
discord.app_commands.Choice(name='Game Night', value=3),
]
)
]
)
async def host(interaction: discord.Interaction, game: int):
await interaction.response.send_message(f"test {game}")
bot.run('your_bot_token_here')
Does it work?
One minute
import discord
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
from discord.ext import commands
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
slash = SlashCommand(bot, sync_commands=True)
@bot.event
async def on_ready():
print('Bot is online')
@slash.slash(
name='host',
description='Host a mg/lg/game night',
options=[
create_option(
name='game',
description='Games to choose from',
option_type=3,
required=True,
choices=[
{"name": "Mag Game", "value": 1},
{"name": "Lob Game", "value": 2},
{"name": "Game Night", "value": 3}
]
)
]
)
async def host(ctx: SlashContext, game: int):
await ctx.send(f"Test {game}")
bot.run('your_bot_token_here')
im using @bot.tree.command
import discord
from discord.ext import commands
from discord_slash import cog_ext
from discord_slash.context import SlashContext
from discord_slash.model import SlashCommandOptionType
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
@bot.event
async def on_ready():
print('Bot is online')
@bot.command(name='host', description='Host a mg/lg/game night')
async def host(ctx: commands.Context):
pass
@cog_ext.cog_subcommand(
base='host',
name='game',
description='Games to choose from'
)
async def game(ctx: SlashContext, game: int):
await ctx.send(f"Test {game}")
bot.run('your_bot_token_here')
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.