コード例 #1
0
ファイル: DKGetPicks.py プロジェクト: nosv1/MoBot
async def getFile(member, moBotMessage, embed, client):
    def checkEmoji(payload):
        return payload.user_id == member.id and payload.channel_id == moBotMessage.channel.id and payload.emoji.name in RandomSupport.numberEmojis

    # end checkEmoji

    embed["description"] = "*Salaries Files:*"
    await editEmbed(moBotMessage, embed)
    dkSalariesDir = os.getcwd() + "\\DKSalaries"
    files = []
    for dir in os.walk(dkSalariesDir):
        for file in dir[-1]:
            if (file[-3:] == "csv" and str(weekNumber + 1) in file):
                files.append(file)
                emojiNumber = RandomSupport.numberToEmojiNumbers(len(files))
                embed[
                    "description"] += "\n" + spaceChar + emojiNumber + " - " + file
                await moBotMessage.add_reaction(emojiNumber)

    embed["description"] += "\n**Select a File Number:**"
    await editEmbed(moBotMessage, embed)
    try:
        payload = await client.wait_for("raw_reaction_add",
                                        timeout=60,
                                        check=checkEmoji)
        file = files[RandomSupport.emojiNumbertoNumber(payload.emoji.name) - 1]
    except asyncio.TimeoutError:
        await moBotMessage.channel.send("**TIMED OUT**")
        file = files[0]

    embed["fields"][0]["value"] = file
    await editEmbed(moBotMessage, embed)
    await moBotMessage.clear_reactions()
    return dkSalariesDir + "\\" + file
コード例 #2
0
ファイル: DKGetPicks.py プロジェクト: nosv1/MoBot
async def printLineup(lineup, moBotMessage, embed):
    embed["fields"][5][
        "value"] = "__Pos. - Player Name - Appg. - Price - Team__"
    playerCount = 0
    remSalary = 50000
    totalAppg = 0
    lineupIDs = ""
    for position in lineup:
        for player in lineup[position]:
            try:
                playerCount += 1
                emojiNumber = RandomSupport.numberToEmojiNumbers(playerCount)
                game = player.game.replace(player.team,
                                           "**" + player.team + "**")
                embed["fields"][5]["value"] += (
                    "\n%s %s - **%s** - %s - %s - %s" %
                    (emojiNumber, position, player.name, player.appg,
                     player.price, game))
                lineupIDs += player.id + ","
                remSalary -= int(player.price)
                totalAppg += float(player.appg)
                await moBotMessage.add_reaction(emojiNumber)
            except AttributeError:  # when not printing full lineup
                print(position, None)
    await moBotMessage.add_reaction(CHECKMARK_EMOJI)
    await moBotMessage.add_reaction(COUNTERCLOCKWISE_ARROWS_EMOJI)
    await moBotMessage.add_reaction(X_EMOJI)
    embed["fields"][5]["value"] += "```%s%s,%.3f```" % (lineupIDs, remSalary,
                                                        totalAppg)
    embed["footer"]["text"] = ("REM. SALARY: $%s TOTAL FPPG: %.3f" %
                               (remSalary, totalAppg))
    await editEmbed(moBotMessage, embed)
コード例 #3
0
ファイル: DKGetPicks.py プロジェクト: nosv1/MoBot
async def getLineupType(member, moBotMessage, embed, client):
    def checkEmoji(payload):
        return payload.user_id == member.id and payload.channel_id == moBotMessage.channel.id and payload.emoji.name in RandomSupport.numberEmojis

    # end checkEmoji

    lineupTypes = ["Classic", "Showdown"]
    embed["description"] = "*Lineup Types:*"
    for i in range(len(lineupTypes)):
        emojiNumber = RandomSupport.numberToEmojiNumbers(i + 1)
        embed[
            "description"] += "\n" + spaceChar + emojiNumber + " - " + lineupTypes[
                i]
        await moBotMessage.add_reaction(emojiNumber)

    embed["description"] += "\n**Select a Lineup Type:**"
    await editEmbed(moBotMessage, embed)
    try:
        payload = await client.wait_for("raw_reaction_add",
                                        timeout=60,
                                        check=checkEmoji)
        lineupType = lineupTypes[
            RandomSupport.emojiNumbertoNumber(payload.emoji.name) - 1]
    except asyncio.TimeoutError:
        await moBotMessage.channel.send("**TIMED OUT**")
        lineupType = lineupTypes[0]

    embed["fields"][1]["value"] = lineupType
    await editEmbed(moBotMessage, embed)
    await moBotMessage.clear_reactions()
    return lineupType