aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Cam Caswell <[email protected]>2021-07-08 20:32:45 -0400
committerGravatar Cam Caswell <[email protected]>2021-07-09 14:02:38 -0400
commitad8ab58d121b3b11c718cbb6cc41dcf6d1491227 (patch)
treeb8e5a8fa13e5274d27bb7c77f02c0f9a064beba6
parentChange the "game over" embed color (diff)
Add stop command for mods
-rw-r--r--bot/exts/evergreen/duck_game.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/bot/exts/evergreen/duck_game.py b/bot/exts/evergreen/duck_game.py
index 0c75c5c3..1661e855 100644
--- a/bot/exts/evergreen/duck_game.py
+++ b/bot/exts/evergreen/duck_game.py
@@ -12,7 +12,7 @@ from PIL import Image, ImageDraw
from discord.ext import commands
from bot.bot import Bot
-from bot.constants import Colours
+from bot.constants import Colours, MODERATION_ROLES
DECK = list(product(*[(0, 1, 2)]*4))
@@ -275,6 +275,17 @@ class DuckGamesDirector(commands.Cog):
"""Explain the rules of the game."""
await self.send_help_embed(ctx)
+ @start_game.command(name="stop")
+ async def stop_game(self, ctx: commands.Context) -> None:
+ """Stop a currently running game. Only available to mods."""
+ if not any(role in ctx.author.roles for role in MODERATION_ROLES):
+ return
+ try:
+ game = self.current_games.pop(ctx.channel.id)
+ except KeyError:
+ return
+ await self.end_game(game, end_message="Game canceled.")
+
@staticmethod
async def send_help_embed(ctx: commands.Context) -> discord.Message:
"""Send rules embed."""