async def declineScore(ctx, ID: int): guild = client.get_guild(guildid) teamID = db.getTeamNumber(ctx.author.id) League_ID = db.getLeagueNumber(ctx.author.id) LeagueInfo = db.getTeamNames(League_ID)[0] scoreChat = discord.utils.get(guild.channels, id=db.getLeagueObjectID(League_ID, "Scores")) score = db.getScore(ID) Team_1 = score[3] Team_2 = score[4] score_1 = score[5] score_2 = score[6] Fixture_Pos = score[2] if (teamID == Team_1 or teamID == Team_2): await ctx.channel.send("Thank you, we will let the League know") db.deleteScore(League_ID, Fixture_Pos) scoreMessage = str(Fixture_Pos) + ": **" + str( score_1) + "**" + " " + str( LeagueInfo[Team_1 + 1]) + " vs " + str( LeagueInfo[Team_2 + 1]) + " " + "**" + str(score_2) + "**" await scoreChat.send("The following score has been **declined** by " + ctx.author.name + ":\n" + scoreMessage) else: await ctx.channel.send("Invalid Submission ID")
async def acceptScore(ctx, ID: int): guild = client.get_guild(guildid) teamID = db.getTeamNumber(ctx.author.id) League_ID = db.getLeagueNumber(ctx.author.id) manager = db.getManager(League_ID, teamID) scoreChat = discord.utils.get(guild.channels, id=db.getLeagueObjectID(League_ID, "Scores")) score = db.getScore(ID) if (ctx.author.id == manager): if (teamID == Team_1 or teamID == Team_2): Team_1 = score[3] Team_2 = score[4] LeagueInfo = db.getTeamNames(League_ID)[0] score_1 = score[5] score_2 = score[6] Fixture_Pos = score[2] db.addFixtureScore(League_ID, Fixture_Pos, score_1, score_2) db.deleteScore(League_ID, Fixture_Pos) await ctx.channel.send("We will add this to the fixtures now!") scoreMessage = str(Fixture_Pos) + ": **" + str( score_1) + "**" + " " + str( LeagueInfo[Team_1 + 1]) + " vs " + str( LeagueInfo[Team_2 + 1]) + " " + "**" + str(score_2) + "**" await scoreChat.send( "The following score has been **accepted** by both managers:\n" + scoreMessage) else: await ctx.channel.send("Invalid Submission ID") else: await ctx.channel.send("You are not a manager!")
async def fixture(ctx, fixturenumber: int): League_ID = db.getLeagueNumber(ctx.author.id) FixtureChat_ID = db.getLeagueObjectID(League_ID, "Fixtures") if (ctx.channel.id == FixtureChat_ID): fixture = db.getFixture(League_ID, fixturenumber) teamnames = db.getTeamNames(League_ID)[0] message = "Here is Fixture " + str(fixturenumber) + ":\n" for match in fixture: if match[5] is None: message = message + str(match[2]) + ": " + str( teamnames[match[3] + 1]) + " vs " + str( teamnames[match[4] + 1]) + " - Due - " + str( match[7])[0:19] + "\n" else: message = message + str(match[2]) + ": **" + str( match[5]) + "**" + " " + str( teamnames[match[3] + 1]) + " vs " + str( teamnames[match[4] + 1]) + " " + "**" + str( match[6]) + "**" + " - Due - " + str( match[7])[0:19] + "\n" await ctx.channel.send(message) else: await ctx.channel.send( "This command must be run in the Fixtures chat of your League")
async def submitScore(ctx, Fixture_Pos: int, homescore: int, awayscore: int): print("Submit Score") guild = client.get_guild(guildid) teamID = db.getTeamNumber(ctx.author.id) League_ID = db.getLeagueNumber(ctx.author.id) LeagueInfo = db.getTeamNames(League_ID)[0] match = db.getMatch(League_ID, Fixture_Pos)[0] #check if home if (teamID == match[3]): print("Im home") db.submitScore(League_ID, Fixture_Pos, homescore, awayscore) awayTeam = match[4] awayManager = LeagueInfo[6 + awayTeam] awayDiscord = discord.utils.get(guild.members, id=int(awayManager)) channel1 = await ctx.author.create_dm() channel2 = await awayDiscord.create_dm() scoreMessage = str(Fixture_Pos) + ": **" + str( homescore) + "**" + " " + str( LeagueInfo[teamID + 1]) + " vs " + str( LeagueInfo[awayTeam + 1]) + " " + "**" + str(awayscore) + "**" subID = db.getScoreSubmitID(League_ID, Fixture_Pos) await channel1.send("You have submitted a score of:\n" + scoreMessage) channel2message = ctx.author.name + " of the team " + str( LeagueInfo[teamID + 1] ) + " has submitted the score:\n" + scoreMessage + "\nIf you would like to accept type !acceptScore " + str( subID ) + "\nIf you would like to decline type !declineScore " + str(subID) await channel2.send(channel2message) #check if away elif (teamID == match[4]): print("Im away") db.submitScore(League_ID, Fixture_Pos, awayscore, homescore) awayTeam = match[3] awayManager = LeagueInfo[6 + awayTeam] awayDiscord = discord.utils.get(guild.members, id=int(awayManager)) channel1 = await ctx.author.create_dm() channel2 = await awayDiscord.create_dm() scoreMessage = str(Fixture_Pos) + ": **" + str( awayscore) + "**" + " " + str( LeagueInfo[awayTeam + 1]) + " vs " + str( LeagueInfo[teamID + 1]) + " " + "**" + str(homescore) + "**" subID = db.getScoreSubmitID(League_ID, Fixture_Pos) await channel1.send("You have submitted a score of:\n" + scoreMessage) channel2message = ctx.author.name + " of the team " + str( LeagueInfo[teamID + 1] ) + " has submitted the score:\n" + scoreMessage + "\nIf you would like to accept type !acceptScore " + str( subID ) + "\nIf you would like to decline type !declineScore " + str(subID) await channel2.send(channel2message) #neither else: await ctx.channel.send("This wasn't your match!")
async def teams(ctx): League_ID = db.getLeagueNumber(ctx.author.id) TeamChat_ID = db.getLeagueObjectID(League_ID, "Team") if (ctx.channel.id == TeamChat_ID): Teams = db.getTeamNames(League_ID) print(Teams[0][0]) print(Teams) message = "These are the teams of the League:\n" message = message + Teams[0][2] + " - Managed by <@" + str( Teams[0][7]) + ">\n" message = message + Teams[0][3] + " - Managed by <@" + str( Teams[0][8]) + ">\n" message = message + Teams[0][4] + " - Managed by <@" + str( Teams[0][9]) + ">\n" message = message + Teams[0][5] + " - Managed by <@" + str( Teams[0][10]) + ">\n" message = message + Teams[0][6] + " - Managed by <@" + str( Teams[0][11]) + ">\n" await ctx.channel.send(message) else: await ctx.channel.send( "This command must be run in the Team chat of your League")
async def staffSetManager(ctx, user: User, *, Team: str): guild = client.get_guild(guildid) League_ID = db.getLeagueID(ctx.channel.id, "Chat") print(League_ID) print(Team) Team_ID = db.getTeamIDByName(League_ID, Team) leagueChat = discord.utils.get(guild.channels, id=db.getLeagueObjectID(League_ID, "Chat")) managerrole = discord.utils.get(guild.roles, name="Manager") player = user.mention.replace("<@", "").replace(">", "") print(player) Teams = db.getTeamNames(League_ID) Old_Manager_ID = Teams[0][6 + Team_ID] Old_Manager = discord.utils.get(guild.members, id=Old_Manager_ID) New_Manager = discord.utils.get(guild.members, id=int(player)) print(New_Manager) New_Manager_Team_ID = db.getTeamNumber(player) New_Manager_League_ID = db.getLeagueNumber(player) if (New_Manager_League_ID != 0): if (New_Manager_Team_ID != 0): if (New_Manager_Team_ID == Team_ID and New_Manager_League_ID == League_ID): teamname = Team db.updateManager(League_ID, Team_ID, New_Manager.id) await Old_Manager.remove_roles(managerrole) await New_Manager.add_roles(managerrole) await leagueChat.send(teamname + "'s manager <@" + str(Old_Manager.id) + "> has resigned and <@" + str(New_Manager.id) + "> has replaced them in the role!") else: await ctx.channel.send("This player is not in your team") else: await ctx.channel.send("This player is not in a Team") else: await ctx.channel.send("This player is not in a League")