#🔒 slash command
33 messages · Page 1 of 1 (latest)
@half meadow
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.
you can use discord.py with bot = commands.Bot(...) to do it (assuming you already use discord.py to make bot before without slash command
if you do not know discord.py and haven't make any discord bot before, it is more recommended to learn make a bot that respond to message first, before shash command
@bot.tree.command(name="...", description="...")
async def slash_command(interaction: discord.Interaction):
await interaction.response.send_message(...)
py-cord
@bot.slash_command(name="...", description="...")
async def slash_command(ctx: discord.ApplicationContext):
await ctx.respond(...)
I've already made several bot discord but not with command /.
Then it's important for us to know what library you used, so people that using the same library might help you better
ive tried making a slash command, it didnt work, then it showed up a day later when the code wasnt even there anymore
lol
I made this
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
# Initialisation du bot
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(bot, sync_commands=True)
# Votre token Discord
TOKEN = 'YOUR_DISCORD_BOT_TOKEN'
# Commande slash simple
@slash.slash(name="hello", description="Dis bonjour!")
async def hello(ctx: SlashContext):
await ctx.send(content="Bonjour!")```
i made ```pip install discord-py-slash-command```
but he can't find it: discord_slash
ah 😢
I've tried but it doesn't detect anything
That other package. discord.py already has slash commands built in
No
Discord uses the library that’s called Interactions
Or smth
discord_slash is outdated
ok thanks. But can you give me a code example so that I can test it with what I need to install on the command line? @short token @wanton light pls
I whish I would have a example myself
Because I wanted to do the same
Im gonna make a bit of research
brb
Uninstall that package. And use the example I showed you. You can also search for examples on Google
ok i try this
Doesn't look like a python, does it?
j'ai écrit ceci :
import discord
from discord.ext import commands
from discord import app_commands
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=« ! », intents=intents)
@bot.event
async def on_ready() :
print(f'Nous nous sommes connectés en tant que {bot.user}')
@bot.tree.command(name=« test », description=« ceci est un test »)
async def slash_command(interaction : discord.Interaction) :
await interaction.response.send_message('test')
bot.run(« TOKEN »)```
Thanks, I'll take a look and let me know if you succeed.
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.