aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar Shivansh-007 <[email protected]>2021-02-08 06:59:24 +0530
committerGravatar Shivansh-007 <[email protected]>2021-02-08 06:59:24 +0530
commit8321add8d6a55132c96a620da2aac5c4bc44c284 (patch)
treef52622fe575ceb5c93598e3905b9b79de8dc7d2a /bot
parentAdd check if game is not intialized (diff)
Use emojis library to do the check instead of checking len() == 1 since some emojis are made of len() > 1
Diffstat (limited to 'bot')
-rw-r--r--bot/exts/evergreen/connect_four.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/bot/exts/evergreen/connect_four.py b/bot/exts/evergreen/connect_four.py
index bf604e2a..02e876f4 100644
--- a/bot/exts/evergreen/connect_four.py
+++ b/bot/exts/evergreen/connect_four.py
@@ -4,6 +4,7 @@ import typing
from functools import partial
import discord
+import emojis
from discord.ext import commands
NUMBERS = [
@@ -342,11 +343,13 @@ class ConnectFour(commands.Cog):
return any(player in (game.player1, game.player2) for game in self.games)
@staticmethod
- def check_emojis(e1: EMOJI_CHECK, e2: EMOJI_CHECK) -> typing.Tuple[bool, typing.Optional[str]]:
+ def check_emojis(
+ e1: EMOJI_CHECK, e2: EMOJI_CHECK
+ ) -> typing.Tuple[bool, typing.Optional[str]]:
"""Validate the emojis, the user put."""
- if isinstance(e1, str) and len(e1) > 1:
+ if isinstance(e1, str) and emojis.count(e1) != 1:
return False, e1
- if isinstance(e2, str) and len(e2) > 1:
+ if isinstance(e2, str) and emojis.count(e2) != 1:
return False, e2
return True, None