async def on_ready(): global LB_CHANNEL await client.change_presence(activity=discord.Game(name="6 mans")) print("Logged in as " + client.user.name + " version " + __version__) try: channel = client.get_channel(QUEUE_CH_IDS[0]) await sendMessage( channel, AdminEmbed(title="Norm Started", desc="Current version: v{0}".format(__version__)), None) await sendMessage(channel, SixMans.listQueue(client.user.name), "queue") except Exception as e: print("! Norm does not have access to post in the queue channel.", e) try: AWS.readRemoteLeaderboard() if (LEADERBOARD_CH_ID != -1): LB_CHANNEL = client.get_channel(LEADERBOARD_CH_ID) # update leaderboard channel when remote leaderboard pulls await Utils.updateLeaderboardChannel(LB_CHANNEL) except Exception as e: # this should only throw an exception if the Leaderboard file does not exist or the credentials are invalid print(e)
async def on_reaction_add(reaction: discord.Reaction, user: discord.User): global LB_CHANNEL if (not user.bot): channel = client.get_channel(QUEUE_CH_IDS[0]) # regional indicator b if (reaction.emoji == "\U0001F1E7" and Queue.isBotAdmin(user.roles)): await reaction.message.delete() await sendMessage(channel, Admin.brokenQueue(user, user.roles), None) await sendMessage(channel, SixMans.listQueue(user), "queue") return elif (reaction.emoji == "🛑" and Queue.isBotAdmin(user.roles)): await reaction.message.delete() await sendMessage(channel, Admin.clear(user.roles), None) await sendMessage(channel, SixMans.listQueue(user), "queue") return # Check to validate reaction is valid by seeing if Norm also reacted with the same reaction reacted_users = await reaction.users().flatten() if (not any(reacted_user.id == client.user.id for reacted_user in reacted_users)): return blueTeam, orangeTeam = Queue.getTeamList() if (reaction.emoji == "✅"): await reaction.message.delete() messages = SixMans.playerQueue(user) for msg in messages: await sendMessage( channel, msg, "popped" if Queue.getQueueLength() == 6 else "queue") elif (reaction.emoji == "❌"): await reaction.message.delete() await sendMessage( channel, SixMans.leave(user), "queue" if Queue.getQueueLength() < 6 else "popped") elif (reaction.emoji == "🤫"): await reaction.message.delete() messages = SixMans.playerQueue(user, quiet=True) for msg in messages: await sendMessage( channel, msg, "popped" if Queue.getQueueLength() == 6 else "queue") elif (reaction.emoji == "🔢"): await reaction.message.delete() await sendMessage( channel, SixMans.leaderboard(client.user.name, "", LEADERBOARD_CH_ID), "popped" if Queue.getQueueLength() == 6 else "queue") elif (reaction.emoji == "❓"): await reaction.message.delete() await sendMessage(channel, HelpEmbed(), None) if (len(blueTeam) >= 1): await sendMessage(channel, SixMans.listQueue(user), "picks") elif (Queue.getQueueLength() == 6 and len(blueTeam) == 0): await sendMessage(channel, SixMans.listQueue(user), "popped") else: await sendMessage(channel, SixMans.listQueue(user), "queue") # regional indicator C elif (reaction.emoji == "\U0001F1E8"): await reaction.message.delete() await sendMessage( channel, SixMans.captains(user), "picks" if Queue.isPlayerInQueue(user) else "popped") # regional indicator R elif (reaction.emoji == "\U0001F1F7"): await reaction.message.delete() if (Queue.isPlayerInQueue(user)): await sendMessage(channel, SixMans.random(user), "active") await sendMessage(channel, SixMans.listQueue(user), "queue") else: await sendMessage(channel, SixMans.random(user), "popped") # regional indicator L elif (reaction.emoji == "\U0001F1F1"): await reaction.message.delete() if (len(blueTeam) == 0 and Queue.getQueueLength() != 6): await sendMessage(channel, SixMans.listQueue(user), "queue") elif (Queue.getQueueLength() == 6 and len(blueTeam) == 0): await sendMessage(channel, SixMans.listQueue(user), "popped") else: await sendMessage(channel, SixMans.listQueue(user), "picks") elif (reaction.emoji == "1️⃣"): await reaction.message.delete() if (Queue.validateOrangePick(user) and len(orangeTeam) == 2): await sendMessage(channel, SixMans.pick(user, 1), "active") await sendMessage(channel, SixMans.listQueue(user), "queue") else: await sendMessage(channel, SixMans.pick(user, 1), "picks") elif (reaction.emoji == "2️⃣"): await reaction.message.delete() if (Queue.validateOrangePick(user) and len(orangeTeam) == 2): await sendMessage(channel, SixMans.pick(user, 2), "active") await sendMessage(channel, SixMans.listQueue(user), "queue") else: await sendMessage(channel, SixMans.pick(user, 2), "picks") elif (reaction.emoji == "3️⃣"): await reaction.message.delete() # if checks not needed here since 3 can never be last pick await sendMessage(channel, SixMans.pick(user, 3), "picks") elif (reaction.emoji == "4️⃣"): await reaction.message.delete() # if checks not needed here since 4 can never be last pick await sendMessage(channel, SixMans.pick(user, 4), "picks") elif (reaction.emoji == "🔷"): response = await SixMans.report(user, LB_CHANNEL, "blue") if (response): await reaction.message.add_reaction("👍") elif (reaction.emoji == "🔶"): response = await SixMans.report(user, LB_CHANNEL, "orange") if (response): await reaction.message.add_reaction("👍") elif (reaction.emoji == "💔" and reaction.count >= 5): # majority vote is 4 + 1 for the bot reaction await sendMessage(channel, SixMans.brokenQueue(user), "queue")