Files
Gwendolyn/cogs/ReactionCog.py
2021-03-29 17:01:01 +02:00

47 lines
2.1 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:
connectFourTheirTurn, piece = self.client.funcs.connectFourReactionTest(channel,message,"#"+str(user.id))
except:
connectFourTheirTurn = False
bedreNetflixMessage, addMovie, imdbIds = self.client.funcs.bedreNetflixReactionTest(channel,message)
if connectFourTheirTurn:
place = emojiToCommand(reaction.emoji)
await self.client.gameLoops.connectFour(message,"place "+str(piece)+" "+str(place),user.id, str(message.channel.id))
elif bedreNetflixMessage and addMovie:
moviePick = emojiToCommand(reaction.emoji)
await message.delete()
if moviePick == "none":
imdbID = None
else:
imdbID = imdbIds[moviePick-1]
await self.client.bedreNetflix.addMovie(channel,imdbID)
elif bedreNetflixMessage and not addMovie:
showPick = emojiToCommand(reaction.emoji)
await message.delete()
if showPick == "none":
imdbName = None
else:
imdbName = imdbIds[showPick-1]
await self.client.bedreNetflix.addShow(channel,imdbName)
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))