Skip to content
This repository was archived by the owner on Aug 29, 2021. It is now read-only.

Commit b172a1e

Browse files
committed
[v0.5.3] Make CCmd initialiasation independent of inject
1 parent 7743992 commit b172a1e

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
## [DiscTools](https://github.com/WizzyGeek/DiscTools)
22

3-
A discord.py helper library
3+
A discord.py helper library <br/>
4+
45
[![Documentation Status](https://readthedocs.org/projects/disctools/badge/?version=latest)](https://disctools.readthedocs.io/en/latest/?badge=latest)
6+
[![Upload Python Package](https://github.com/WizzyGeek/DiscTools/actions/workflows/python-publish.yml/badge.svg)](https://github.com/WizzyGeek/DiscTools/actions/workflows/python-publish.yml)
57

68
### [Documentation](https://disctools.readthedocs.io)
79

disctools/__version_info__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __repr__(self) -> str:
2020
}
2121

2222
class last_modified:
23-
day = 17
23+
day = 18
2424
month = 5
2525
year = 2021
2626

@@ -93,7 +93,7 @@ def __repr__(self) -> str:
9393
version_info = VersionInfo(
9494
major = 0,
9595
minor = 5,
96-
patch = 2,
96+
patch = 3,
9797
status = status_map["final"],
9898
)
9999

disctools/commands.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@ class CCmd(Command[Context], _Group, metaclass=CogCommandType, _root=True):
398398
399399
Also called :class:`CogCmd`
400400
"""
401+
def __init__(self, func: Optional[AsyncCallable] = None, **kwargs) -> None:
402+
super().__init__(func=func, **kwargs)
403+
if self.__class__.__fut_sub_cmds__:
404+
for i in self.__class__.__fut_sub_cmds__.values():
405+
self.add_command(i)
406+
i.cogcmd = self
407+
self.__class__.__fut_sub_cmds__ = False
408+
401409
def copy(self):
402410
ret = super(Command, self).copy()
403411
for cmd in map(lambda x: x.copy(), self.commands):
@@ -466,10 +474,5 @@ class MyCmd(Command):
466474
def decorator(cls: Type[G]) -> G:
467475
if isinstance(cls, _Command):
468476
raise TypeError("Can not inject a command instance, expected a <class 'type'>")
469-
if issubclass(cls, CCmd):
470-
self = cls(**kwargs)
471-
for i in cls.__fut_sub_cmds__.values():
472-
self.add_command(i)
473-
i.cogcmd = self
474477
return cls(**kwargs)
475478
return decorator

version.num

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.2
1+
0.5.3

0 commit comments

Comments
 (0)