From 96744f0c110d38e938104bffc6bedd441046694f Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Fri, 16 Dec 2016 11:02:55 -0600 Subject: [PATCH] Added the ability to force stop a running blackjack game --- cogs/blackjack.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cogs/blackjack.py b/cogs/blackjack.py index 1d269a2..93e0cde 100644 --- a/cogs/blackjack.py +++ b/cogs/blackjack.py @@ -84,6 +84,24 @@ class Blackjack: else: await self.bot.say("Either you have already bet, or you are not even playing right now!") + @blackjack.command(pass_context=True, no_pm=True, name='forcestop') + @utils.custom_perms(manage_server=True) + async def blackjack_leave(self, ctx): + """Forces the game to stop, mostly for use if someone has gone afk + + EXAMPLE: !blackjack forcestop + RESULT: No more blackjack spam""" + + # Get this server's game if it exists + game = self.games.get(ctx.message.server.id) + + if game is None: + await self.bot.say("There are currently no games of Blackjack running!") + return + + game.task.cancel() + await self.bot.say("The blackjack game running here has just ended") + def FOIL(a, b): """Uses FOIL to calculate a new possible total (who knew math would come in handy?!)