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)
def fill(roles: List[Role]) -> Embed: if (Queue.isBotAdmin(roles)): TestHelper.fillQueue() return AdminEmbed(title="Queue Filled", desc="Queue has been filled with fake/real players") return ErrorEmbed(title="Permission Denied", desc="You do not have permission to fill the queue.")
def flipCap(roles: List[Role]) -> Embed: if (Queue.isBotAdmin(roles)): TestHelper.flipCaptains() return AdminEmbed(title="Captains Flipped", desc="Captains have been flipped.") return ErrorEmbed(title="Permission Denied", desc="You do not have permission to flip the captains.")
def flipReport(roles: List[Role]) -> Embed: if (Queue.isBotAdmin(roles)): TestHelper.swapReportedPlayer() return AdminEmbed(title="Reported Player Swapped", desc="The player who reported has been swapped out.") return ErrorEmbed( title="Permission Denied", desc="You do not have permission to flip the reporting player.")
def update(roles: List[Role]) -> Embed: """ Middleware function to check author's permissions before running the update script. Parameters: roles: List[discord.Role] - The roles of the author of the message. Returns: dicord.Embed - The embedded message to respond with. """ if(Queue.isBotAdmin(roles)): updateBot() return AdminEmbed( title="Already Up to Date", desc="Current version: v{0}".format(__version__) ) return AdminEmbed( title="Permission Denied", desc="You do not have permission to check for updates." )
async def forceReport(mentions: str, roles: List[Role], lbChannel: Channel, *arg) -> Embed: if (Queue.isBotAdmin(roles)): if (len(arg) == 2 and "<@!" in arg[0]): split = mentions.split("<@!") if (str(arg[1]).lower() == Team.BLUE): player_id = split[1][:-6] elif(str(arg[1]).lower() == Team.ORANGE): player_id = split[1][:-8] else: return ErrorEmbed( title="You Must Report A Valid Team", desc="You did not supply a valid team to report." ) if (player_id.isdigit()): msg = reportMatch(player_id, arg[1], True) if (msg): try: # if match was reported successfully, update leaderboard channel await updateLeaderboardChannel(lbChannel) except Exception as e: print("! Norm does not have access to update the leaderboard.", e) return AdminEmbed( title="Match Force Reported Successfully", desc="You may now re-queue." ) else: return ErrorEmbed( title="Did Not Mention a Player", desc="You must mention one player who is in the match you want to report." ) else: ErrorEmbed( title="Did Not Mention a Player", desc="You must mention one player who is in the match you want to report." ) else: return ErrorEmbed( title="Permission Denied", desc="You do not have the strength to force report matches. Ask an admin if you need to force report a match." # noqa )
def clear(roles: List[Role]) -> Embed: """ Clears the current queue if the author has the Bot Admin role. Parameters: roles: List[discord.Role] - The roles of the author of the message. Returns: dicord.Embed - The embedded message to respond with. """ if(Queue.isBotAdmin(roles)): Queue.clearQueue() return AdminEmbed( title="Queue Cleared", desc="The queue has been cleared by an admin. <:UNCCfeelsgood:538182514091491338>" ) return ErrorEmbed( title="Permission Denied", desc="You do not have permission to clear the queue." )
def kick(mentions: str, roles: List[Role], *arg) -> Embed: """ Kicks the mentioned player from the queue. Requires Bot Admin role. Parameters: mentions: str - The content of the message. roles: List[discord.Role] - The roles of the author of the message. *arg: - The arguments in the message. Returns: discord.Embed - The embedded message to respond with. """ blueTeam, orangeTeam = Queue.getTeamList() blueCap, orangeCap = Queue.getCaptains() if (len(arg) > 0 and "<@!" in arg[0]): split = mentions.split("<@!") player_id = split[1][:-1] if (player_id.isdigit()): embed = None if (not Queue.isBotAdmin(roles)): embed = ErrorEmbed( title="Permission Denied", desc="You do not have the leg strength to kick other players." ) elif (Queue.queueAlreadyPopped()): embed = ErrorEmbed( title="Queue Already Popped", desc="Can't kick players while picking teams." ) elif (Queue.getQueueLength() == 0): embed = ErrorEmbed( title="Queue is Empty", desc="The queue is empty, what are you doing?" ) elif (not Queue.isPlayerInQueue(player_id)): embed = ErrorEmbed( title="User Not in Queue", desc="To see who is in current queue, type: **!list**" ) else: member = Queue.getPlayerFromQueue(player_id) Queue.removeFromQueue(player_id) embed = AdminEmbed( title="Kicked Player", desc="Removed {0} from the queue".format(member["name"].split("#")[0]) ) edited_embed = CaptainsRandomHelpEmbed(embed, blueTeam, orangeTeam, blueCap, orangeCap) return edited_embed embed = ErrorEmbed( title="Did Not Mention a Player", desc="Please mention a player in the queue to kick." ) edited_embed = CaptainsRandomHelpEmbed(embed, blueTeam, orangeTeam, blueCap, orangeCap) return edited_embed
def restart(): return AdminEmbed( title="Command Diasbled", desc="This command is temporarily disabled." )
async def update(ctx): await ctx.send(embed=AdminEmbed(title="Checking For Updates", desc="Please hang tight.")) await ctx.send(embed=Admin.update(ctx.message.author.roles))