#🔒 slash command

33 messages · Page 1 of 1 (latest)

half meadow
#

I'm making a bot discord and I'd like to know how to make slash commands in python.

young islandBOT
#

@half meadow

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.

patent sinew
#

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

short token
half meadow
patent sinew
#

Then it's important for us to know what library you used, so people that using the same library might help you better

half meadow
knotty hatch
#

ive tried making a slash command, it didnt work, then it showed up a day later when the code wasnt even there anymore

#

lol

half meadow
# short token discord.py ```py @bot.tree.command(name="...", description="...") async def slas...

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
half meadow
short token
wanton light
#

No

#

Discord uses the library that’s called Interactions

#

Or smth

#

discord_slash is outdated

half meadow
#

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

wanton light
#

I whish I would have a example myself

#

Because I wanted to do the same

#

Im gonna make a bit of research

#

brb

short token
wanton light
half meadow
half meadow
# short token Uninstall that package. And use the example I showed you. You can also search fo...

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 »)```
half meadow
young islandBOT
#
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.