Skip to content

Commit

Permalink
Add force option to Dragonfly stop command (#64)
Browse files Browse the repository at this point in the history
* Add option to specify force task shutdown

* Bump version and update changelog

* Lint

* Update docs/source/changelog.rst

Co-authored-by: Bradley Reynolds <[email protected]>
Signed-off-by: Robin <[email protected]>

---------

Signed-off-by: Robin <[email protected]>
Co-authored-by: Bradley Reynolds <[email protected]>
  • Loading branch information
Robin5605 and shenanigansd authored May 5, 2023
1 parent 3fa2df4 commit 7caf47c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Changelog
=========

- :release:`2.2.0 <5th May 2023>`
- :feature:`57` Add force option to Dragonfly stop command

- :release:`2.1.0 <3rd May 2023>`
- :feature:`59` Add slash command to bring up package modal on demand

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "alessia"
version = "2.1.0"
version = "2.2.0"
dependencies = [
"python-dotenv==1.0.0",
"discord.py==2.2.2",
Expand Down
10 changes: 7 additions & 3 deletions src/bot/exts/dragonfly/dragonfly.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,14 @@ async def start(self, ctx: commands.Context) -> None:
await ctx.send("Started task...")

@commands.command()
async def stop(self, ctx: commands.Context) -> None:
async def stop(self, ctx: commands.Context, force: bool = False) -> None:
if self.scan_loop.is_running():
self.scan_loop.stop()
await ctx.send("Stopping task...")
if force:
self.scan_loop.cancel()
await ctx.send("Forcing shutdown...")
else:
self.scan_loop.stop()
await ctx.send("Executing graceful shutdown...")
else:
await ctx.send("Task is not running.")

Expand Down

0 comments on commit 7caf47c

Please sign in to comment.