Skip to content

Commit dc7ead8

Browse files
committed
Update migrate_to_109.rst
1 parent c74c2a9 commit dc7ead8

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/migrate_to_109.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,48 @@ After:
6060
channel_id = ctx.channel_id
6161
guild_id = ctx.guild_id
6262
...
63+
64+
65+
Cog Support
66+
***********
67+
68+
Before:
69+
70+
.. code-block:: python
71+
72+
class Slash(commands.Cog):
73+
def __init__(self, bot):
74+
if not hasattr(bot, "slash"):
75+
# Creates new SlashCommand instance to bot if bot doesn't have.
76+
bot.slash = SlashCommand(bot, override_type=True)
77+
self.bot = bot
78+
self.bot.slash.get_cog_commands(self)
79+
80+
def cog_unload(self):
81+
self.bot.slash.remove_cog_commands(self)
82+
83+
...
84+
85+
After:
86+
87+
.. code-block:: python
88+
89+
class Slash(commands.Cog):
90+
def __init__(self, bot):
91+
if not hasattr(bot, "slash"):
92+
# Creates new SlashCommand instance to bot if bot doesn't have.
93+
bot.slash = SlashCommand(bot, override_type=True)
94+
self.bot = bot
95+
96+
...
97+
98+
Note that removing `if not hasattr(...):` block then moving to main file like this is also recommended.
99+
100+
.. code-block:: python
101+
102+
bot = commands.Bot(...)
103+
slash = SlashCommand(bot)
104+
# No worries for not doing `bot.slash` because its automatically added now.
105+
...
106+
107+

0 commit comments

Comments
 (0)