31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from discord.ext import commands
|
|
|
|
from funcs import logThis, emojiToCommand
|
|
|
|
class ReactionCog(commands.Cog):
|
|
def __init__(self, client):
|
|
"""Listens for reactions."""
|
|
self.client = client
|
|
|
|
@commands.Cog.listener()
|
|
async def on_reaction_add(self, reaction,user):
|
|
if user.bot == False:
|
|
message = reaction.message
|
|
channel = message.channel
|
|
logThis(user.display_name+" reacted to a message",str(channel.id))
|
|
try:
|
|
fourInARowTheirTurn, piece = self.client.funcs.fiarReactionTest(channel,message,"#"+str(user.id))
|
|
except:
|
|
fourInARowTheirTurn = False
|
|
|
|
if fourInARowTheirTurn:
|
|
place = emojiToCommand(reaction.emoji)
|
|
await self.client.gameLoops.fiar(channel," place "+str(piece)+" "+str(place),user.id)
|
|
elif self.client.funcs.monopolyReactionTest(channel,message):
|
|
await self.client.gameLoops.runMonopoly(channel,"roll","#"+str(user.id))
|
|
elif self.client.funcs.hangmanReactionTest(channel,message) and ord(reaction.emoji) in range(127462,127488):
|
|
guess = chr(ord(reaction.emoji)-127397)
|
|
await self.client.gameLoops.runHangman(channel,"#"+str(user.id),command="guess "+guess)
|
|
def setup(client):
|
|
client.add_cog(ReactionCog(client))
|