Esempio n. 1
0
async def makeManager(ctx, user: User):
    guild = client.get_guild(guildid)
    Team_ID = db.getTeamNumber(ctx.author.id)
    League_ID = db.getLeagueNumber(ctx.author.id)
    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)
    #find old manage
    Old_Manager = discord.utils.get(guild.members, id=ctx.author.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 = db.getTeamName(ctx.author.id)
                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")
Esempio n. 2
0
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")
Esempio n. 3
0
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!")
Esempio n. 4
0
async def invite(ctx, user: User):
    guild = client.get_guild(guildid)
    player = user.mention.replace("<@", "").replace(">", "")
    invitee = discord.utils.get(guild.members, id=int(player))
    teamID = db.getTeamNumber(ctx.author.id)
    leagueID = db.getLeagueNumber(ctx.author.id)
    xbox_free_agent = discord.utils.get(guild.channels,
                                        name="free-agents-xbox")
    ps4_free_agent = discord.utils.get(guild.channels, name="free-agents-ps4")
    if (ctx.channel.id == xbox_free_agent.id
            or ctx.channel.id == ps4_free_agent.id):
        if (db.getInviteID(leagueID, teamID, invitee.id) == 0
                and db.getLeagueNumber(invitee.id) == 0):
            print(invitee)
            print(invitee.id)
            #create Invite and get team name and ID
            teamname = db.getTeamName(ctx.author.id)

            db.invitePlayer(leagueID, teamID, invitee.id)
            inviteID = db.getInviteID(leagueID, teamID, invitee.id)
            try:
                channel1 = await ctx.author.create_dm()
                await channel1.send("You have invited " + invitee.name +
                                    " to join your team " + teamname)
            except:
                await ctx.channel.send(
                    "Check your DM settings, something went wrong so we will post this here. \n"
                    + "<@" + str(ctx.author.id) + ">" + "You have invited " +
                    invitee.name + " to join your team " + teamname)
            try:
                channel2 = await invitee.create_dm()
                await channel2.send(
                    "You have been invited to join team " + teamname + " by " +
                    ctx.author.name +
                    "\n Type the following to accept: \n !accept " +
                    str(inviteID) +
                    "\n or type the following to decline: \n !decline " +
                    str(inviteID))
            except:
                await ctx.channel.send(
                    "Check your DM settings, something went wrong so we will post this here. \n"
                    + "<@" + str(ctx.author.id) + ">"
                    "You have been invited to join team " + teamname + " by " +
                    ctx.author.name +
                    "\n Type the following to accept: \n !accept " +
                    str(inviteID) +
                    "\n or type the following to decline: \n !decline " +
                    str(inviteID))
        else:
            await ctx.channel.send(
                "This player has already been invited or are already in a League!"
            )
    else:
        await ctx.channel.send(
            "This command can only be used in the free agents channels")
Esempio n. 5
0
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!")
Esempio n. 6
0
async def kick(ctx, user: User):
    guild = client.get_guild(guildid)
    Team_ID = db.getTeamNumber(ctx.author.id)
    League_ID = db.getLeagueNumber(ctx.author.id)
    leagueChat = discord.utils.get(guild.channels,
                                   id=db.getLeagueObjectID(League_ID, "Chat"))
    player = user.mention.replace("<@", "").replace(">", "")
    print(player)
    Old_Manager = discord.utils.get(guild.members, id=ctx.author.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 = db.getTeamName(ctx.author.id)
                leagueRole = discord.utils.get(guild.roles,
                                               id=db.getLeagueObjectID(
                                                   League_ID, "Role"))
                await New_Manager.remove_roles(leagueRole)
                db.deletePlayer(New_Manager.id)
                await leagueChat.send(
                    "<@" + str(New_Manager.id) +
                    ">'s contract has been terminated from " + teamname + "!")
                DMNotice = await New_Manager.create_dm()
                await DMNotice.send(
                    "Sorry to inform you but your contract for the team " +
                    teamname + " has been terminated!")
            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")
Esempio n. 7
0
async def leaveLeague(ctx):
    guild = client.get_guild(guildid)
    League_ID = db.getLeagueNumber(ctx.author.id)
    Team_ID = db.getTeamNumber(ctx.author.id)
    leagueRole = discord.utils.get(guild.roles,
                                   id=db.getLeagueObjectID(League_ID, "Role"))

    if (League_ID != 0):
        manager = db.getManager(League_ID, Team_ID)
        if (ctx.author.id == manager):
            await ctx.channel.send(
                "You are a manager so you cannot leave the league until you transfer ownership."
            )
        else:
            Member = discord.utils.get(guild.members, id=int(ctx.author.id))
            await Member.remove_roles(leagueRole)
            db.deletePlayer(ctx.author.id)
    else:
        await ctx.channel.send("You are not part of a League!")