Repository: Rapptz/discord.py
Pull request: Add basic slash command example
## Summary

Adding app_command examples. Preferred structure:
```
examples/
  app_commands/
    cog.py
    groups.py
    basic.py
    context_menu.py
    checks.py
    hybrid.py
```

## Checklist

<!-- Put an x inside [ ] to check it, like so: [x] -->

- [ ] If code changes were made then they have been tested.
    - [ ] I have updated the documentation to reflect the changes.
- [x] This PR fixes #7941
- [ ] This PR adds something new (e.g. new method or parameters).
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
- [x] This PR is **not** a code change (e.g. documentation, README, ...)


Problem statement:
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_

Hints from issue discussion:

Commit message: Add basic slash command example

Patch to review:
diff --git a/examples/app_commands/basic.py b/examples/app_commands/basic.py
new file mode 100644
index 000000000000..72d405c12ca7
--- /dev/null
+++ b/examples/app_commands/basic.py
@@ -0,0 +1,58 @@
+import discord
+from discord import app_commands
+from discord.ext import commands
+
+class MyBot(commands.Bot):
+
+    # In this basic example, we just synchronize the app commands to one guild,
+    # without requiring to set the guild to every command individually by just coping them over.
+    # By doing so we don't have to wait up to 1hr until they are shown for the end-user.
+
+    # If you want to synchronize your app commands to every guild your bot is in, 
+    # remove the following setup_hook and uncomment the one below.
+    async def setup_hook(self):
+        # Replace ... with the guild id you want your commands to be synced with.
+        guild = discord.Object(...)
+        self.tree.copy_global_to(guild=guild)
+        synced_app_commands = await self.tree.sync(guild=guild)
+        print(f'Synced the following commands to {guild.id}: {[c.name for c in synced_app_commands]}')
+
+    # async def setup_hook(self):
+    #     synced_app_commands = await self.tree.sync()
+    #     print(f'Synced the following commands to every guild: {[c.name for c in synced_app_commands]}')
+
+intents = discord.Intents.default()
+
+# In order to use a basic synchronization of the app commands in the setup_hook, 
+# you have replace ... with your bots application_id you find in the developer portal.
+bot = MyBot(command_prefix='?', intents=intents, application_id=...)
+
+
+@bot.event
+async def on_ready():
+    print(f'Logged in as {bot.user} (ID: {bot.user.id})')
+    print('------')
+
+@bot.tree.command()
+async def hello(interaction: discord.Interaction):
+    """Says hello!"""
+    await interaction.response.send_message(f'Hi, {interaction.user.mention}')
+
+@bot.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 make it a default argument
+@bot.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: discord.Member = None):
+    """Says when a member joined."""
+    # By doing this we use the member that was provided, 
+    # tho if this is None we use the user that has invoked the command
+    member = member or interaction.user
+
+    await interaction.response.send_message(f'{member} joined in {member.joined_at}')
+
+bot.run('token')
\ No newline at end of file


Code review comments:
diff_hunk: @@ -0,0 +1,58 @@
+import discord
+from discord import app_commands
+from discord.ext import commands
+
+class MyBot(commands.Bot):
+
+    # In this basic example, we just synchronize the app commands to one guild,
+    # without requiring to set the guild to every command individually by just coping them over.
path: examples/app_commands/basic.py
text: @user1:
```suggestion
    # without requiring to set the guild to every command individually by just copying them over.
```
typo

@author:
Thanks