Skip to content

Commit 6075239

Browse files
committed
Fix invalid code in documentation for cog support
1 parent 0c1b04f commit 6075239

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,34 @@ This example serves as an alternative method for using slash commands in a cog i
7272

7373
```py
7474
# bot.py
75-
from discord import Client, Intents, Embed
76-
from discord_slash import SlashCommand, SlashContext
77-
78-
bot = Client(intents=Intents.default())
75+
from discord import Intents
76+
from discord.ext.commands import Bot
77+
from discord_slash import SlashCommand
78+
79+
# Note that command_prefix is a required but essentially unused paramater.
80+
# Setting help_command=False ensures that discord.py does not create a !help command.
81+
# Enabling self_bot ensures that the bot does not try and parse messages that start with "!".
82+
bot = Bot(command_prefix="!", self_bot=True, help_command=False, intents=Intents.default())
7983
slash = SlashCommand(bot)
8084

8185
bot.load_extension("cog")
8286
bot.run("discord_token")
8387

8488
# cog.py
8589
from discord import Embed
90+
from discord.ext.commands import Bot, Cog
8691
from discord_slash import cog_ext, SlashContext
8792

88-
class Slash(commands.Cog):
89-
def __init__(self, bot):
93+
class Slash(Cog):
94+
def __init__(self, bot: Bot):
9095
self.bot = bot
9196

9297
@cog_ext.cog_slash(name="test")
9398
async def _test(self, ctx: SlashContext):
9499
embed = Embed(title="Embed Test")
95100
await ctx.send(embed=embed)
96-
97-
def setup(bot):
101+
102+
def setup(bot: Bot):
98103
bot.add_cog(Slash(bot))
99104
```
100105

0 commit comments

Comments
 (0)