Repository: Rapptz/discord.py

Issue:
Should Add application_commands usage in examples
### Summary

will you add appcommands usage in examples 

### What is the feature request for?

The core library

### The Problem

it's difficult to make a slash commands in discord.py for beginners, because docs are not well documented, may be discord.py guide will be release soon but for now please add some basic or advance example of slash commands in examples folder, for getting an idea of how to make it....

### The Ideal Solution

By adding that, it will be easy for those who are reverting back to discord.py from other 3rd party libraries, or else make a guide for all application commands, discord.ui Components, like other 3rd party libraries

it is available by another developers as a gist, but it may be not accessible to all

### The Current Solution

_No response_

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/examples/app_commands/basic.py b/examples/app_commands/basic.py
new file mode 100644
--- /dev/null
+++ b/examples/app_commands/basic.py
@@ -0,0 +1,71 @@
+from typing import Optional
+
+import discord
+from discord import app_commands
+
+MY_GUILD = discord.Object(id=0)  # replace with your guild id
+
+
+class MyClient(discord.Client):
+    def __init__(self, *, intents: discord.Intents, application_id: int):
+        super().__init__(intents=intents, application_id=application_id)
+        # A CommandTree is a special type that holds all the application command
+        # state required to make it work. This is a separate class because it
+        # allows all the extra state to be opt-in.
+        # Whenever you want to work with application commands, your tree is used
+        # to store it and work with it.
+        # Note: When using commands.Bot instead of discord.Client, the bot will
+        # maintain its own tree instead.
+        self.tree = app_commands.CommandTree(self)
+
+    # In this basic example, we just synchronize the app commands to one guild.
+    # Instead of specifying a guild to every command, we copy over our global commands instead.
+    # By doing so we don't have to wait up to an hour until they are shown to the end-user.
+    async def setup_hook(self):
+        # This copies the global commands over to your guild.
+        self.tree.copy_global_to(guild=MY_GUILD)
+        await self.tree.sync(guild=MY_GUILD)
+
+
+intents = discord.Intents.default()
+
+# In order to use a basic synchronization of the app commands in the setup_hook,
+# you have replace the 0 with your bots application_id you find in the developer portal.
+client = MyClient(intents=intents, application_id=0)
+
+
+@client.event
+async def on_ready():
+    print(f'Logged in as {client.user} (ID: {client.user.id})')
+    print('------')
+
+
+@client.tree.command()
+async def hello(interaction: discord.Interaction):
+    """Says hello!"""
+    await interaction.response.send_message(f'Hi, {interaction.user.mention}')
+
+
+@client.tree.command()
+@app_commands.describe(
+    first_value='The first value you want to add something to',
+    second_value='The value you want to add to the first value',
+)
+async def add(interaction: discord.Interaction, first_value: int, second_value: int):
+    """Adds two numbers together."""
+    await interaction.response.send_message(f'{first_value} + {second_value} = {first_value + second_value}')
+
+
+# To make an argument optional, you can either give it a supported default argument
+# or you can mark it as Optional from the typing library. This example does both.
+@client.tree.command()
+@app_commands.describe(member='The member you want to get the joined date from, defaults to the user who uses the command')
+async def joined(interaction: discord.Interaction, member: Optional[discord.Member] = None):
+    """Says when a member joined."""
+    # If no member is explicitly provided then we use the command user here
+    member = member or interaction.user
+
+    await interaction.response.send_message(f'{member} joined in {member.joined_at}')
+
+
+client.run('token')


Test patch: