Skip to content

Commit ba925ca

Browse files
authored
feat: add poll option to jurriged ext
* Added polling kwarg to jurigged ext * Added docs for jurigged polling
1 parent 49e26d8 commit ba925ca

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

docs/src/Guides/22 Live Patching.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ That's it! The extension will handle all of the leg work, and all you'll notice
1717
## How is this useful?
1818

1919
interactions.py takes advantage of jurigged to reload any and all commands that were edited whenever a change is made, allowing you to have more uptime with while still adding/improving features of your bot.
20+
21+
## It's not working inside Docker!
22+
To make `jurigged` work inside Docker container, you need to mount the directory you're working in as a volume in the container (pointing to the code directory inside the container).
23+
24+
Additionally, you need to initialize the `jurigged` extension with the `poll` keyword argument set to `True`:
25+
26+
```py
27+
bot.load_extension("interactions.ext.jurigged", poll=True)
28+
```

interactions/ext/jurigged.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from types import ModuleType
44
from typing import Callable, Dict
55

6-
from interactions import Extension, SlashCommand
6+
from interactions import Extension, SlashCommand, Client
77
from interactions.client.errors import ExtensionLoadException, ExtensionNotFound
88
from interactions.client.utils.misc_utils import find
99
from interactions.client.const import get_logger
@@ -55,15 +55,19 @@ def is_slashcommand(e) -> bool:
5555

5656

5757
class Jurigged(Extension):
58+
def __init__(self, *_, poll=False) -> None:
59+
self.poll = poll
60+
self.command_cache = {}
61+
self.watcher = None
62+
5863
async def async_start(self) -> None:
5964
"""Jurigged starting utility."""
60-
self.command_cache = {}
6165
self.bot.logger.warning("Setting sync_ext to True by default for syncing changes")
6266
self.bot.sync_ext = True
6367

6468
self.bot.logger.info("Loading jurigged")
6569
path = Path().resolve()
66-
self.watcher = watch(f"{path}/[!.]*.py", logger=self.jurigged_log)
70+
self.watcher = watch(f"{path}/[!.]*.py", logger=self.jurigged_log, poll=self.poll)
6771
self.watcher.prerun.register(self.jurigged_prerun)
6872
self.watcher.postrun.register(self.jurigged_postrun)
6973

@@ -203,5 +207,8 @@ def jurigged_postrun(self, _path: str, cf: CodeFile) -> None: # noqa: C901
203207
self.command_cache.clear()
204208

205209

206-
def setup(bot) -> None:
207-
Jurigged(bot)
210+
def setup(
211+
bot: Client,
212+
poll: bool = False,
213+
) -> None:
214+
Jurigged(bot, poll=poll)

0 commit comments

Comments
 (0)