Python
pip install -U discord-py-slash-command
Python
import discord
from discord_slash import SlashCommand # Importing the newly installed library.
from discord.ext import commands
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(bot, sync_commands=True)
# Ready Event
@bot.event
async def on_ready():
print('Logged in as {0.user}'.format(bot))
# Commands Here...
client.run("your_bot_token_here")
Python
@slash.slash(name="test", description="This is just a test command, nothing more.")
async def test(ctx):
await ctx.send(content="Hello World!")
This is a simple command called test
that writes Hello Wolrd!
after a user executes the command.
Python
@slash.slash(name="test", description="This is just a test command, nothing more.", options=[
create_option(
name="option1",
description="The description for the option",
option_type=3,
required=True
)
])