Skip to content

Commit

Permalink
Merge pull request #4 from RB387/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
RB387 authored Oct 9, 2021
2 parents 1138640 + 2a4e78d commit ceae18f
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Python Discord Music Bot
Easy to extend and support

![Bot play](https://raw.githubusercontent.com/RB387/py-discord-music-bot/master/.git_images/play.png)


## Supported commands
```
!play [url or name] - play song from any stream/video or youtube search
!loop - enable/disable queue loop
!queue - current bot song queue
!pause - pause current song
!resume - resume paused song
Expand Down Expand Up @@ -55,6 +59,41 @@ pip install -r test-requirements.txt
pytest tests/
```

## How to add new command
Just create new class with `handle` method and add `router.command` decorator

To register this command import it in `lib/commands/__init__.py`

For auto help generation add `__doc__` for your new command

## Dependency Injection
You can create commands with dependencies

All you need is just add them to class signature
Injector will resolve and inject all classes with magic methods `__connect__`, `__disconnect__` from `ClientProtocol` interface

Also, you can initialize clients from config. Just add `__from_config__` method from `FileConstructable` interface

#### Example
```python
from dataclasses import dataclass
from lib.core.injector import ClientProtocol
from lib.core.router import router


class MyClient(ClientProtocol):
def do(self):
print('DID SOMETHING')


@router.command('command')
@dataclass
class MyCommand:
client: MyClient # will be auto injected

async def handle(self, ctx):
self.client.do()
```

## TODO
* Write tests on bot business logic
* Add loop queue
* Write tests on bot business logic

0 comments on commit ceae18f

Please sign in to comment.