Fix invalid code in documentation for cog support
@@ -72,10 +72,14 @@ This example serves as an alternative method for using slash commands in a cog i
```py
# bot.py
-from discord import Client, Intents, Embed
-from discord_slash import SlashCommand, SlashContext
-
-bot = Client(intents=Intents.default())
+from discord import Intents
+from discord.ext.commands import Bot
+from discord_slash import SlashCommand
+
+# Note that command_prefix is a required but essentially unused paramater.
+# Setting help_command=False ensures that discord.py does not create a !help command.
+# Enabling self_bot ensures that the bot does not try and parse messages that start with "!".
+bot = Bot(command_prefix="!", self_bot=True, help_command=False, intents=Intents.default())
slash = SlashCommand(bot)
bot.load_extension("cog")
@@ -83,10 +87,11 @@ bot.run("discord_token")
# cog.py
from discord import Embed
+from discord.ext.commands import Bot, Cog
from discord_slash import cog_ext, SlashContext
-class Slash(commands.Cog):
- def __init__(self, bot):
+class Slash(Cog):
+ def __init__(self, bot: Bot):
self.bot = bot
@cog_ext.cog_slash(name="test")
@@ -94,7 +99,7 @@ class Slash(commands.Cog):
embed = Embed(title="Embed Test")
await ctx.send(embed=embed)
-def setup(bot):
+def setup(bot: Bot):
bot.add_cog(Slash(bot))
```
