cogwatch


Namecogwatch JSON
Version 3.3.1 PyPI version JSON
download
home_pagehttps://github.com/robertwayne/cogwatch
SummaryAutomatic hot-reloading for your discord.py (or other supported libaries) command files.
upload_time2023-04-02 15:01:31
maintainer
docs_urlNone
authorRob Wagner
requires_python>=3.10,<4.0
licenseMIT
keywords discord.py discord bot cogs hot-reload nextcord py-cord pycord disnake discord4py
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">Cog Watch</h1>
    
<div align="center">
  <strong><i>Automatic hot-reloading for your discord.py command files.</i></strong>
  <br />
  <br />
  
  <a href="https://pypi.org/project/cogwatch">
    <img
      src="https://img.shields.io/pypi/v/cogwatch?color=0073B7&label=Latest&style=for-the-badge"
      alt="Version" />
  </a>
  
  <a href="https://python.org">
    <img
      src="https://img.shields.io/pypi/pyversions/cogwatch?color=0073B7&style=for-the-badge"
      alt="Python Version" />
  </a>
</div>
<br />

`cogwatch` is a utility that you can plug into your `discord.py` bot *(or
various supported bot libraries)* that will watch your command files directory
*(cogs)* and automatically reload them as you modify or move them around in
real-time.

No more reloading your commands manually every time you edit an embed just to
make sure it looks perfect!

<img align="center" src="assets/example.png" alt=""> <br />

## Features

- Automatically reloads commands in real-time as you edit them *(no !reload
  <command_name> needed)*.
- Optionally handles the loading of all your commands on start-up *(removes
  boilerplate)*.

## Supported Libraries

`cogwatch` *should* work with any library that forked from `discord.py`.
However, these libraries have been explicitly tested to work:

- [discord.py](https://discordpy.readthedocs.io/en/stable/)
- [nextcord](https://docs.nextcord.dev/en/stable/)
- [discord4py](https://docs.discord4py.dev/en/developer/)
- [disnake](https://disnake.readthedocs.io/en/latest/)
- [pycord](https://docs.pycord.dev/en/stable/)

## Getting Started

You can install the library with `pip install cogwatch`.

Import the `watch` decorator and apply it to your `on_ready` method and let the
magic take effect.

See the [examples](/examples) directory for more details.

```python
import asyncio
from discord.ext import commands
from cogwatch import watch


class ExampleBot(commands.Bot):
    def __init__(self):
        super().__init__(command_prefix='!')

    @watch(path='commands', preload=True) # This is all you need to add.
    async def on_ready(self):
        print('Bot ready.')

    async def on_message(self, message):
        if message.author.bot:
            return

        await self.process_commands(message)


async def main():
    client = ExampleBot()
    await client.start('YOUR_TOKEN_GOES_HERE')

if __name__ == '__main__':
    asyncio.run(main())
```

## Configuration

These options can be passed to the decorator *(or the class if manually
initializing)*:

`path`: Path of the directory where your command files exist; cogwatch will
watch recursively within this directory. **Defaults to 'commands'**.

`preload`: Whether to detect and load all cogs on start. **Defaults to False.**

`colors`: Whether to use colorized terminal outputs or not. **Defaults to
True.**

`default_logger`: Whether to use the default logger *(to sys.stdout)* or not.
**Defaults to True.**

`loop`: Custom event loop. **Defaults to the current running event loop.**

`debug`: Whether to run the bot only when the Python **\_\_debug\_\_** flag is
True. **Defaults to True.**

**NOTE:** `cogwatch` will only run if the **\_\_debug\_\_** flag is set on
Python. You can read more about that
[here](https://docs.python.org/3/library/constants.html). In short, unless you
run Python with the *-O* flag from your command line, **\_\_debug\_\_** will be
**True**. If you just want to bypass this feature, pass in `debug=False` and it
won't matter if the flag is enabled or not.

## Logging

By default, the utility has a logger configured so users can get output to the
console. You can disable this by passing in `default_logger=False`. If you want
to hook into the logger -- for example, to pipe your output to another terminal
or `tail` a file -- you can set up a custom logger like so:

```python
import logging
import sys

watch_log = logging.getLogger('cogwatch')
watch_log.setLevel(logging.INFO)
watch_handler = logging.StreamHandler(sys.stdout)
watch_handler.setFormatter(logging.Formatter('[%(name)s] %(message)s'))
watch_log.addHandler(watch_handler)
```

## License

cogwatch is available under the **[MIT License](/LICENSE)**.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/robertwayne/cogwatch",
    "name": "cogwatch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "discord.py,discord bot,cogs,hot-reload,nextcord,py-cord,pycord,disnake,discord4py",
    "author": "Rob Wagner",
    "author_email": "rob@sombia.com",
    "download_url": "https://files.pythonhosted.org/packages/4d/96/049bc937245dcc2c6e49f94ef58de0544b0e64ea22b7034c08880447c34f/cogwatch-3.3.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">Cog Watch</h1>\n    \n<div align=\"center\">\n  <strong><i>Automatic hot-reloading for your discord.py command files.</i></strong>\n  <br />\n  <br />\n  \n  <a href=\"https://pypi.org/project/cogwatch\">\n    <img\n      src=\"https://img.shields.io/pypi/v/cogwatch?color=0073B7&label=Latest&style=for-the-badge\"\n      alt=\"Version\" />\n  </a>\n  \n  <a href=\"https://python.org\">\n    <img\n      src=\"https://img.shields.io/pypi/pyversions/cogwatch?color=0073B7&style=for-the-badge\"\n      alt=\"Python Version\" />\n  </a>\n</div>\n<br />\n\n`cogwatch` is a utility that you can plug into your `discord.py` bot *(or\nvarious supported bot libraries)* that will watch your command files directory\n*(cogs)* and automatically reload them as you modify or move them around in\nreal-time.\n\nNo more reloading your commands manually every time you edit an embed just to\nmake sure it looks perfect!\n\n<img align=\"center\" src=\"assets/example.png\" alt=\"\"> <br />\n\n## Features\n\n- Automatically reloads commands in real-time as you edit them *(no !reload\n  <command_name> needed)*.\n- Optionally handles the loading of all your commands on start-up *(removes\n  boilerplate)*.\n\n## Supported Libraries\n\n`cogwatch` *should* work with any library that forked from `discord.py`.\nHowever, these libraries have been explicitly tested to work:\n\n- [discord.py](https://discordpy.readthedocs.io/en/stable/)\n- [nextcord](https://docs.nextcord.dev/en/stable/)\n- [discord4py](https://docs.discord4py.dev/en/developer/)\n- [disnake](https://disnake.readthedocs.io/en/latest/)\n- [pycord](https://docs.pycord.dev/en/stable/)\n\n## Getting Started\n\nYou can install the library with `pip install cogwatch`.\n\nImport the `watch` decorator and apply it to your `on_ready` method and let the\nmagic take effect.\n\nSee the [examples](/examples) directory for more details.\n\n```python\nimport asyncio\nfrom discord.ext import commands\nfrom cogwatch import watch\n\n\nclass ExampleBot(commands.Bot):\n    def __init__(self):\n        super().__init__(command_prefix='!')\n\n    @watch(path='commands', preload=True) # This is all you need to add.\n    async def on_ready(self):\n        print('Bot ready.')\n\n    async def on_message(self, message):\n        if message.author.bot:\n            return\n\n        await self.process_commands(message)\n\n\nasync def main():\n    client = ExampleBot()\n    await client.start('YOUR_TOKEN_GOES_HERE')\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n## Configuration\n\nThese options can be passed to the decorator *(or the class if manually\ninitializing)*:\n\n`path`: Path of the directory where your command files exist; cogwatch will\nwatch recursively within this directory. **Defaults to 'commands'**.\n\n`preload`: Whether to detect and load all cogs on start. **Defaults to False.**\n\n`colors`: Whether to use colorized terminal outputs or not. **Defaults to\nTrue.**\n\n`default_logger`: Whether to use the default logger *(to sys.stdout)* or not.\n**Defaults to True.**\n\n`loop`: Custom event loop. **Defaults to the current running event loop.**\n\n`debug`: Whether to run the bot only when the Python **\\_\\_debug\\_\\_** flag is\nTrue. **Defaults to True.**\n\n**NOTE:** `cogwatch` will only run if the **\\_\\_debug\\_\\_** flag is set on\nPython. You can read more about that\n[here](https://docs.python.org/3/library/constants.html). In short, unless you\nrun Python with the *-O* flag from your command line, **\\_\\_debug\\_\\_** will be\n**True**. If you just want to bypass this feature, pass in `debug=False` and it\nwon't matter if the flag is enabled or not.\n\n## Logging\n\nBy default, the utility has a logger configured so users can get output to the\nconsole. You can disable this by passing in `default_logger=False`. If you want\nto hook into the logger -- for example, to pipe your output to another terminal\nor `tail` a file -- you can set up a custom logger like so:\n\n```python\nimport logging\nimport sys\n\nwatch_log = logging.getLogger('cogwatch')\nwatch_log.setLevel(logging.INFO)\nwatch_handler = logging.StreamHandler(sys.stdout)\nwatch_handler.setFormatter(logging.Formatter('[%(name)s] %(message)s'))\nwatch_log.addHandler(watch_handler)\n```\n\n## License\n\ncogwatch is available under the **[MIT License](/LICENSE)**.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automatic hot-reloading for your discord.py (or other supported libaries) command files.",
    "version": "3.3.1",
    "split_keywords": [
        "discord.py",
        "discord bot",
        "cogs",
        "hot-reload",
        "nextcord",
        "py-cord",
        "pycord",
        "disnake",
        "discord4py"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "35f1dba4865b83c92cbadb8e85c09eb8f4059fd272a6777d135450d11dd28ea7",
                "md5": "e0c566699c75f1859b658695ba17c083",
                "sha256": "727aef54a92261b704ccafa6a23ec5a0f0fb3e9e25cf8a6c8ef24cf2e6c73d1f"
            },
            "downloads": -1,
            "filename": "cogwatch-3.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e0c566699c75f1859b658695ba17c083",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 8107,
            "upload_time": "2023-04-02T15:01:30",
            "upload_time_iso_8601": "2023-04-02T15:01:30.005957Z",
            "url": "https://files.pythonhosted.org/packages/35/f1/dba4865b83c92cbadb8e85c09eb8f4059fd272a6777d135450d11dd28ea7/cogwatch-3.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d96049bc937245dcc2c6e49f94ef58de0544b0e64ea22b7034c08880447c34f",
                "md5": "a57d5847555c87a838ba4ec8294ae8a1",
                "sha256": "102408b97196ca13ed95af9fa2cda22db8e3d6ba71bfaafa1098231da7b963fb"
            },
            "downloads": -1,
            "filename": "cogwatch-3.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a57d5847555c87a838ba4ec8294ae8a1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7299,
            "upload_time": "2023-04-02T15:01:31",
            "upload_time_iso_8601": "2023-04-02T15:01:31.182243Z",
            "url": "https://files.pythonhosted.org/packages/4d/96/049bc937245dcc2c6e49f94ef58de0544b0e64ea22b7034c08880447c34f/cogwatch-3.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-02 15:01:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "robertwayne",
    "github_project": "cogwatch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cogwatch"
}
        
Elapsed time: 0.12010s