Automatic hot-reloading for your discord.py command files.
Project description
cogwatch
Automatic hot-reloading for your discord.py command files.
cogwatch
is a utility that you can plug into your discord.py
bot that will watch your command files directory (cogs)
and automatically reload them as you modify or move them around in real-time. No more manually reloading commands with
other commands, or (worse) restarting your bot, every time you edit that embed!
Getting Started
You can install the library with pip install cogwatch
.
You can import and start the watcher anywhere you want, as long as you have access to your initialized bot class. The
on_ready
method makes a good, generic location. The first two arguments are required. The first is your bot instance.
The second is the name of the directory where your command files exist. All other arguments are optional.
from cogwatch import watch
@watch()
async def on_ready(self):
pass
By default the library will use the running event loop. If you wish to pass in a specific loop, you can do so with the
loop=None
parameter.
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. This is a development tool. You should not run it on production.
There is a complete example bot in the examples/ directory that shows all the arguments.
Logging
By default the library has a logger enabled 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cogwatch-1.1.0.tar.gz
.
File metadata
- Download URL: cogwatch-1.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.0b5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6e69f9b966c1670d89f1967ef7fddaa3083dc6ef879c6c6e2794e5f578e2bd |
|
MD5 | 9d21a133eaf588b82218b520f7b9b9c3 |
|
BLAKE2b-256 | d00f4e28e7203243af694ab1ef2200b91b195c31e12b3b3494c3afd829b436c2 |
Provenance
File details
Details for the file cogwatch-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: cogwatch-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.9.0b5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 390e2361cd6c883a3038792cf6240cb2242eed62965409bf55a907922049ef15 |
|
MD5 | 45a30dc3100da18cf6e25b9f24b963fb |
|
BLAKE2b-256 | 98984b96b96fdfbd1262f0d1f77ec1931daacfe8506cf33561f89970ed637692 |