diff options
| author | 2020-04-07 14:39:01 +0300 | |
|---|---|---|
| committer | 2020-04-07 14:39:01 +0300 | |
| commit | 88762008d4fc36744f1dc5507a90015a37a0a9eb (patch) | |
| tree | ecc99ede5ac6ee77eeef5346f2b7e57490b7b03a | |
| parent | (TicTacToe): Added new variable `games` to `TicTacToe` cog. (diff) | |
(TicTacToe): Created check `is_channel_free`.
| -rw-r--r-- | bot/exts/evergreen/tic_tac_toe.py | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/evergreen/tic_tac_toe.py index 28f48e11..301cb9ff 100644 --- a/bot/exts/evergreen/tic_tac_toe.py +++ b/bot/exts/evergreen/tic_tac_toe.py @@ -2,7 +2,7 @@ import asyncio  import typing as t  import discord -from discord.ext.commands import Cog, Context +from discord.ext.commands import Cog, Context, check  from bot.bot import SeasonalBot  from bot.constants import Emojis @@ -82,6 +82,13 @@ class TicTacToe(Cog):          self.bot = bot          self.games: t.List[Game] = [] +    @staticmethod +    def is_channel_free() -> t.Callable: +        """Check is channel where command will be invoked free.""" +        async def predicate(ctx: Context) -> bool: +            return all(game.channel != ctx.channel for game in ctx.cog.games) +        return check(predicate) +  def setup(bot: SeasonalBot) -> None:      """Load TicTacToe Cog.""" | 
