Cog Watch
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!
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:
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 directory for more details.
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. 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:
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.
Metadata
Release files for cogwatch 3.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cogwatch-3.3.1.tar.gz | 7.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cogwatch-3.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.4 kB
Release files / cogwatch-3.3.1.tar.gz
| Download URL | cogwatch-3.3.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
102408b97196ca13ed95af9fa2cda22db8e3d6ba71bfaafa1098231da7b963fb
|
|
BLAKE2b-256 checksum How to use checksums |
4d96049bc937245dcc2c6e49f94ef58de0544b0e64ea22b7034c08880447c34f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.10 Linux/6.2.8-arch1-1
|
Release files / cogwatch-3.3.1-py3-none-any.whl
| Download URL | cogwatch-3.3.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
727aef54a92261b704ccafa6a23ec5a0f0fb3e9e25cf8a6c8ef24cf2e6c73d1f
|
|
BLAKE2b-256 checksum How to use checksums |
35f1dba4865b83c92cbadb8e85c09eb8f4059fd272a6777d135450d11dd28ea7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.10 Linux/6.2.8-arch1-1
|
Security for cogwatch 3.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.