コード例 #1
0
async def yes(bot, ctx):
    data = openMM()
    for i in range(len(data)):
        i = str(i)
        if data[i]["callerid"] == ctx.message.author.id and data[i]["confirmcaller"] == False:
            data[i]["confirmcaller"] = True
            saveMM(data)
            await bot.send_message(bot.get_channel(data[i]["channelid"]),
                                   embed=um.buildBaseEmbed(ctx.message.author, "Middleman Call",
                                                           "Succesfully confirmed the trade."))

            if data[i]["confirmcaller"] == True and data[i]["confirmpartner"] == True:
                await bot.send_message(bot.get_channel(data[i]["channelid"]),
                                       embed=um.buildBaseEmbed(ctx.message.author, "Middleman Call",
                                                               "Both accepted the trade. A middleman will be with you shortly."))
                await callMiddleMan(bot, ctx, i)
        elif data[i]["partnerid"] == ctx.message.author.id and data[i]["confirmpartner"] == False:
            data[i]["confirmpartner"] = True
            saveMM(data)
            await bot.send_message(bot.get_channel(data[i]["channelid"]),
                                   embed=um.buildBaseEmbed(ctx.message.author, "Middleman Call",
                                                           "Succesfully confirmed the trade."))
            if data[i]["confirmcaller"] == True and data[i]["confirmpartner"] == True:
                await bot.send_message(bot.get_channel(data[i]["channelid"]),
                                       embed=um.buildBaseEmbed(ctx.message.author, "Middleman Call",
                                                               "Both accepted the trade. A middleman will be with you shortly."))

                await callMiddleMan(bot, ctx, i)
コード例 #2
0
async def gettrade(ctx, id):
    if not checkPermitted(ctx.message.author):
        return um.buildBaseEmbed(ctx.message.author, "Middleman Database", "You aren't a certified middleman.")
    data = openMM()
    if id is not None:
        em = um.buildBaseEmbed(ctx.message.author, "Middleman Database", "{0} saved trades.".format(len(data)))
        em.add_field(name="Trade {0}".format(id), value="\u200b  **Caller**: {0}\n"
                                                        "  **Partner**: {1}\n"
                                                        "  **Middleman**: {2}\n"
                                                        "  **Description**: {3}\n"
                                                        "  **ID**: {4}\n"
                                                        "  **Platform**: {5}".format(
            ctx.message.server.get_member(
                data[id][
                    "callerid"]).mention,
            ctx.message.server.get_member(
                data[id][
                    "partnerid"]).mention,
            ctx.message.server.get_member(
                data[id][
                    "middlemanid"]).mention,
            data[id]["description"], data[id]["id"], data[id]["platform"]))
    else:
        em = um.buildBaseEmbed(ctx.message.author, "Middleman Database",
                               "{0} saved trades. (0-{1}).".format(len(data), len(data) - 1))
    return em
コード例 #3
0
async def deleterep(ctx, user: discord.Member, number: int):
    if ctx.message.channel.id in permittedchannels:
        if ctx.message.author.id in op:
            await bot.say(embed=UsefulMethods.deleteREP(user, number))
        else:
            await bot.say(embed=UsefulMethods.buildBaseEmbed(ctx.message.author, "Deleting Rep",
                                                             "You don't have enough permissions to do this."))
コード例 #4
0
async def gettrades(ctx, user):
    if not checkPermitted(ctx.message.author):
        return um.buildBaseEmbed(ctx.message.author, "Middleman Database", "You aren't a certified middleman.")
    data = openMM()
    tradeids = []
    for i in range(len(data)):
        i = str(i)
        if data[i]["middlemanid"] == user.id and not data[i]["active"]:
            tradeids.append(i)

    if len(tradeids) > 0:
        em = um.buildBaseEmbed(user, "Middleman Database", "{0} saved trades.".format(len(tradeids)))
        for i in tradeids:
            em.add_field(name="Trade {0}".format(i), value="\u200b  **Caller**: {0}\n"
                                                           "  **Partner**: {1}\n"
                                                           "  **Middleman**: {2}\n"
                                                           "  **Description**: {3}\n"
                                                           "  **ID**: {4}\n"
                                                           "  **Platform**: {5}".format(
                ctx.message.server.get_member(
                    data[i][
                        "callerid"]).mention,
                ctx.message.server.get_member(
                    data[i][
                        "partnerid"]).mention,
                ctx.message.server.get_member(
                    data[i][
                        "middlemanid"]).mention,
                data[i]["description"], data[i]["id"], data[i]["platform"]))
    else:
        em = um.buildBaseEmbed(user, "Middleman Database", "This Middleman has 0 saved trades.".format(len(tradeids)))
    return em
コード例 #5
0
async def close(bot, ctx, id):
    if not checkPermitted(ctx.message.author):
        return um.buildBaseEmbed(ctx.message.author, "Middleman System", "You aren't a certified middleman.")
    data = openMM()
    data[id]["active"] = False
    saveMM(data)

    for msg in [ctx.message.id, data[id]["callmessageid"]]:
        await bot.delete_message(await bot.get_message(ctx.message.channel, msg))

    await bot.delete_channel(ctx.message.server.get_channel(data[id]["channelid"]))

    await bot.send_message(um.getChannel(bot, "mm-logs"),
                           embed=um.buildBaseEmbed(ctx.message.author, "Middleman System".format(id),
                                                   "Trade {0} closed".format(id)).add_field(name="Trade Stats",
                                                                                            value="\u200b  **Caller**: {0}\n"
                                                                                                  "  **Partner**: {1}\n"
                                                                                                  "  **Middleman**: {2}\n"
                                                                                                  "  **Description**: {3}\n"
                                                                                                  "  **Platform**: {5}\n"
                                                                                                  "  **ID**: {4}".format(
                                                                                                ctx.message.server.get_member(
                                                                                                    data[id][
                                                                                                        "callerid"]).mention,
                                                                                                ctx.message.server.get_member(
                                                                                                    data[id][
                                                                                                        "partnerid"]).mention,
                                                                                                ctx.message.server.get_member(
                                                                                                    data[id][
                                                                                                        "middlemanid"]).mention,
                                                                                                data[id]["description"],
                                                                                                data[id]["id"], data[id]["platform"])))
コード例 #6
0
async def delete(ctx, id, bot=None):
    if not checkPermitted(ctx.message.author):
        return um.buildBaseEmbed(ctx.message.author, "Middleman Database", "You aren't a certified middleman.")
    data = openMM()
    if data[id]["active"]:
        await bot.delete_channel(ctx.message.server.get_channel(data[id]["channelid"]))
    del data[id]
    saveMM(data)
    return um.buildBaseEmbed(ctx.message.author, "Middleman Database", "Succesfully deleted trade {0}".format(id))
コード例 #7
0
async def clear(bot, author, channel, number):
    number = 100 if number > 100 else number
    for role in author.roles:
        if role.name in Constants.permissionLevel1 or author.id == Constants.ownerid:
            await bot.purge_from(channel=channel, limit=number + 1)
            return um.buildBaseEmbed(
                author, ";clear",
                "Succesfully cleared {} messages.".format(number))
    return um.buildBaseEmbed(author, ";clear",
                             "You don't have enough permissions to do this!")
コード例 #8
0
def stats_embed(member):
    if not checkJSON(member):
        return UsefulMethods.buildBaseEmbed(member, "Activity System",
                                            "No recorded data")

    return [
        UsefulMethods.buildBaseEmbed(member,
                                     "Activity Stats for {}".format(member),
                                     stats(member.id)[0]),
        stats(member.id)[1]
    ]
コード例 #9
0
async def openCrate(bot, ctx, crate):
    crate = crate.lower()
    author = ctx.message.author
    if not crate in crates:
        return UsefulMethods.buildBaseEmbed(author, "Crate Opening",
                                            "Invalid Crate")
    data = openJSONCheck(author.id, author)

    if data["crates"][author.id][crate] > 0:
        data["crates"][author.id][crate] -= 1

        rarity = openCrate_Rarity(crate)

        item = random.choice(items[rarity])
        shiny = openCrate_Shiny(crate, rarity)
        shiny_msg = ""
        if shiny:
            shiny_msg = "***shiny*** "

        # data["crates"][author.id]["items"][rarity].append(item)
        addItemToInventory(item, shiny,
                           data["crates"][author.id]["items"][rarity])

        saveJSON(data)
        # await bot.add_roles(author, UsefulMethods.getRole(ctx.message.server, winning))

        # role = discord.utils.find(lambda r: r.name == item, author.server.roles)
        roles = []
        colour = 0xFFFFFF
        for r in author.server.roles:
            if r.name.lower() == item.lower():
                roles.append(r)

        # print(shiny, "--------------------------------------------")

        if shiny:
            for r in roles:
                for p in r.permissions:
                    if ("change_nickname", True) == p:
                        colour = r.colour
        else:
            for r in roles:
                for p in r.permissions:
                    if ("change_nickname", False) == p:
                        print(r.name, r.colour)
                        colour = r.colour

        return UsefulMethods.buildBaseEmbed(
            author, "Crate Opening",
            "You got a(n) **{0}** role: {2}**{1}**!".format(
                rarity, item, shiny_msg), colour)
    else:
        return UsefulMethods.buildBaseEmbed(author, "Crate Opening",
                                            "You don't have enough crates!")
コード例 #10
0
async def give_crate(author, receiver, crate, amount):
    if not crate.lower() in crates:
        return UsefulMethods.buildBaseEmbed(author, "Crate System Error",
                                            "Invalid Crate.")
    if not author.id in Constants.permissionLevel9000:
        return UsefulMethods.buildBaseEmbed(author, "Crate System Error",
                                            "Invalid Permissions.")
    data = openJSONCheck(receiver.id, receiver)
    data["crates"][receiver.id][crate.lower()] += amount
    saveJSON(data)
    return UsefulMethods.buildBaseEmbed(
        author, "Crate System",
        "Succesfully added {} {} crates to {} inventory.".format(
            amount, crate, receiver.mention))
コード例 #11
0
async def call(ctx, trade_partner: discord.Member, platform: str, *, description: str):
    cmd = ctx.message.content.split(" ", 3)
    if not cmd[2].lower() in ["pc", "ps4", "xbox", "switch"]:
        await bot.say(embed=UsefulMethods.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                         "Correct usage: **!call** `@TradePartner` `platform` `description`."))
        return
    await MiddlemanCommands.call(bot, ctx, trade_partner, platform, description)
コード例 #12
0
def draw_inv(author, bot):
    draw = createTransparentPicture()
    font = ImageFont.truetype("arial.ttf", 30)

    data = CrateCommands.openJSONCheck(author.id, author)
    crates = data["crates"][author.id]

    # crate_balance = "\u200b  Mincoin: {}\n".format(crates["minicoin"])
    crate_balance = "\u200b"

    if crates["regular"] > 0:
        crate_balance += "\u200b  Regular Crates: {}\n".format(crates["regular"])
    if crates["golden"] > 0:
        crate_balance += "\u200b  Golden Crates: {}\n".format(crates["golden"])
    if crates["diamond"] > 0:
        crate_balance += "\u200b  Diamond Crates: {}\n".format(crates["diamond"])
    if crates["master"] > 0:
        crate_balance += "\u200b  Master Crates: {}\n".format(crates["master"])

    if crate_balance == "\u200b":
        pass

    else:
        draw.text((100, 100), crate_balance, (255, 255, 255), font=font)

        embed = UsefulMethods.buildBaseEmbed(author, "{0}'s Inventory".format(author.name), crate_balance)
コード例 #13
0
async def trade(bot, channel, author, receiver, roles):
    for i in range(30):
        if checkIfRoleExists(roles[:i]):
            item1 = roles[:i]
            item2 = roles[i + 1:]

    inv1 = openJSONCheck(author.id, author)["crates"][author.id]["items"]
    inv2 = openJSONCheck(receiver.id, receiver)["crates"][author.id]["items"]

    if not itemIsInInv(inv1, item1):
        return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                            "You don't own this role.")
    if not itemIsInInv(inv2, item2):
        return UsefulMethods.buildBaseEmbed(
            author, "Crate System",
            "{} doesn't own this role.".format(receiver.mention))

    await bot.send_message(
        channel,
        "You want to trade `{}` for `{}` with {}. Accept your trade with `yes`."
        .format(item1.title(), item2.title(), receiver.mention))

    msg = await bot.wait_for_message(timeout=10, author=author, content="yes")

    if not msg:
        return UsefulMethods.buildBaseEmbed(
            author, "Crate System", "Canceled trade.".format(receiver.mention))

    await bot.send_message(
        channel,
        "{2} please accept the trade with `yes`. You will get `{0}` for `{1}`".
        format(item1.title(), item2.title(), receiver.mention))

    msg = await bot.wait_for_message(timeout=10,
                                     author=receiver,
                                     content="yes")
    if not msg:
        return UsefulMethods.buildBaseEmbed(
            author, "Crate System", "Canceled trade.".format(receiver.mention))
    # receiver add
    addItemToInventory(item1)
    ########################### SHINY VERGESSEN SCHON GANZ OBEN!!!!!!!!!!!!!!!!!!!!!!!!!!

    return UsefulMethods.buildBaseEmbed(
        author, "Crate System",
        "Succesfully traded {}'s {} for {}'s {}".format(
            author.mention, item1.title(), receiver.mention, item2.title()))
コード例 #14
0
async def on_reaction_add(bot, reaction, user):
    if reaction.emoji.name in Constants.reactions and not user.bot:
        await bot.add_roles(
            user, UsefulMethods.getRole(user.server, reaction.emoji.name))
        await bot.send_message(
            user, "You successfully added {} to your profile!".format(
                reaction.emoji))

        await bot.remove_reaction(reaction.message, reaction.emoji, user)

    elif reaction.emoji.name.startswith("delete") and not user.bot:
        await bot.remove_reaction(reaction.message, reaction.emoji, user)

        for emoji in Constants.reaction_json[reaction.replace("delete_", "")]:
            while UsefulMethods.getRole(user.server, emoji) in user.roles:
                await bot.remove_roles(
                    user, UsefulMethods.getRole(user.server, emoji))
コード例 #15
0
async def show_roles(bot, author, rarity):
    roles = ""
    for r in items[rarity.lower()]:
        roles += "{} {} {}\n".format("\u200b", "\U000025CF", r)

    return UsefulMethods.buildBaseEmbed(author,
                                        "{} Roles".format(rarity.title()),
                                        roles)
コード例 #16
0
async def add_role(bot, author, rarity, item):
    if rarity not in tiers:
        return UsefulMethods.buildBaseEmbed(author, "Crate System Error",
                                            "Invalid Rarity.")
    if not author.id in Constants.permissionLevel9000:
        return UsefulMethods.buildBaseEmbed(author, "Crate System Error",
                                            "Invalid Permissions.")

    current_items = loadCrateItems()
    current_items[rarity].append(item)

    saveCrateItems(current_items)

    reload_items()

    return UsefulMethods.buildBaseEmbed(
        author, "Crate System",
        "Succesfully added {} as a(n) {} role.".format(item, rarity))
コード例 #17
0
async def cancel(bot, ctx):
    data = openMM()

    for i in range(len(data)):
        i = str(i)
        if data[i]["callerid"] == ctx.message.author.id and data[i]["active"] and data[i]["middlemanid"] is None:
            await bot.delete_channel(ctx.message.server.get_channel(data[i]["channelid"]))
            msg = await bot.send_message(ctx.message.channel,
                                         embed=um.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                                 "Succesfully canceled middleman call {}.".format(
                                                                     i)))
            del data[i]
            saveMM(data)
            await asyncio.sleep(5)
            await bot.delete_message(msg)
            return

    await bot.send_message(ctx.message.channel, embed=um.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                                        "You don't have an open middleman call or a middleman accepted the call."))
コード例 #18
0
async def equip(bot, item, author):
    inv = openJSON()["crates"][author.id]["items"]
    shiny = False
    item_check = item
    if item.lower().startswith("s."):
        shiny = True
        item_check = item[2:]
    elif item.lower().startswith("shiny "):
        shiny = True
        item_check = item[6:]
        item = "Ss." + item[6:]

    if item.lower() == "mvp":
        item = "MVP"
    else:
        item = item.title()
    if not checkIfRoleExists(item_check):
        return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                            "This role doesn't exist")
    try:
        for rarity in inv:
            for i in inv[rarity]:
                if i.lower() == item.lower():
                    if inv[rarity][item]["am"] >= 1 and inv[rarity][item][
                            "shiny"] == shiny:
                        await bot.add_roles(
                            author,
                            getRole(author.server, i if not shiny else i[2:],
                                    shiny))
                        return UsefulMethods.buildBaseEmbed(
                            author, "Crate System",
                            "Equipped {}**{}** succesfully.".format(
                                "***shiny*** " if shiny else "", item))
    except IndentationError:
        return UsefulMethods.buildBaseEmbed(
            author, "Error",
            "Something went wrong, please dm {}. Thank you!".format(
                discord.utils.find(lambda u: u.id == Constants.ownerid,
                                   author.server.members).mention))

    return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                        "You don't own this role.")
コード例 #19
0
async def rankreactionsetup(bot):
    for s in bot.servers:
        for c in s.channels:
            if c.name == "rules-and-roles":
                async for m in bot.logs_from(c, limit=10):
                    if m.content.startswith("Please select your platform."):
                        await bot.delete_message(m)
                msg = await bot.send_message(c,
                                             "Please select your platform. React with :x: to clear all your platform roles.")
                for e in ["pc", "ps4", "1xbox", "switch"]:
                    await bot.add_reaction(msg, UsefulMethods.getEmoji(bot, e))
                await bot.add_reaction(msg, "\U0000274C")
コード例 #20
0
async def callMiddleMan(bot, ctx, id):
    data = openMM()
    msg = await bot.send_message(getMiddlemanChannel(ctx.message.server),
                                 getMiddlemanRole(ctx.message.server, data[id]["platform"]).mention,
                                 embed=um.buildBaseEmbed(ctx.message.author, "Middleman Needed",
                                                         "{0} and {1} require assistance in `{3}`, ID: `{2}`, Platform `{4}`. Type `!confirm {2}` to accept the case.".format(
                                                             ctx.message.server.get_member(
                                                                 data[id]["callerid"]).mention,
                                                             ctx.message.server.get_member(
                                                                 data[id]["partnerid"]).mention,
                                                             id, data[id]["description"], data[id]["platform"])))
    data[id]["callmessageid"] = msg.id
    saveMM(data)
コード例 #21
0
async def startup(bot):
    channel = UsefulMethods.getChannel(bot, "settings-selection")
    async for m in bot.logs_from(channel, limit=20):
        if m.author.id == bot.user.id:
            await bot.delete_message(m)

    await bot.send_file(channel, "data/reactionsSetup/settings.png")
    await bot.send_file(channel, "data/reactionsSetup/minibord.png")
    await bot.send_message(
        channel,
        "**1- What games would you like to see? Press :x: to clear all roles.**"
    )
    game_message = await bot.send_file(channel,
                                       "data/reactionsSetup/minisetting.png")

    for emoji in Constants.game_emojis:
        e = UsefulMethods.getEmoji(bot, emoji)
        await bot.add_reaction(game_message, e)
    await bot.add_reaction(game_message,
                           UsefulMethods.getEmoji(bot, "delete_games"))

    await bot.send_file(channel, "data/reactionsSetup/minibord.png")
    platform_message = await bot.send_message(
        channel,
        "**2- What platform do you play on? Press :x: to clear all roles.**")

    for emoji in Constants.platform_emojis:
        e = UsefulMethods.getEmoji(bot, emoji)
        await bot.add_reaction(platform_message, e)
    await bot.add_reaction(platform_message,
                           UsefulMethods.getEmoji(bot, "delete_platforms"))

    await bot.send_file(channel, "data/reactionsSetup/minibord.png")
    await bot.send_message(
        channel,
        "**3- What notifications would you like to receive? Press :x: to clear all roles.**"
    )
    notification_message = await bot.send_file(
        channel, "data/reactionsSetup/notifications.png")
    for emoji in Constants.notification_emojis:
        e = UsefulMethods.getEmoji(bot, emoji)
        await bot.add_reaction(notification_message, e)
    await bot.add_reaction(notification_message,
                           UsefulMethods.getEmoji(bot, "delete_notifications"))

    await bot.send_file(channel, "data/reactionsSetup/minibord.png")
    await bot.send_message(
        channel,
        "For every 1 **partnership ping**, the participants are rewarded with 1 Mincoin :mincoin: \
                    Aiding us with partnerships will help this server grow and help us provide better content for you, help us help you!"
    )
コード例 #22
0
async def confirm(bot, ctx, id):
    if not checkPermitted(ctx.message.author):
        return um.buildBaseEmbed(ctx.message.author, "Middleman System", "You aren't a certified middleman.")

    data = openMM()
    data[str(id)]["middlemanname"] = ctx.message.author.name
    data[str(id)]["middlemanid"] = ctx.message.author.id
    readperm = discord.PermissionOverwrite(read_messages=True)

    print(data[id]["callmessageid"])

    await bot.edit_channel_permissions(ctx.message.server.get_channel(data[id]["channelid"]),
                                       ctx.message.author, readperm)

    await bot.delete_message(await bot.get_message(ctx.message.channel, data[id]["callmessageid"]))
    await bot.delete_message(ctx.message)
    print("Save MM.json")

    msg = await bot.send_message(ctx.message.channel, embed=um.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                                              "You are a middleman in trade{0} now. Make sure to `!close {0}` the trade if the trade finished or `!delete {0}` if the trade failed.".format(
                                                                                  id)).add_field(name="Trade Members",
                                                                                                 value="Caller: {0}, Partner: {1}.".format(
                                                                                                     ctx.message.server.get_member(
                                                                                                         data[id][
                                                                                                             "callerid"]).mention,
                                                                                                     ctx.message.server.get_member(
                                                                                                         data[id][
                                                                                                             "partnerid"]).mention),
                                                                                                 inline=False).add_field(
        name="Trade Description", value=data[id]["description"], inline=False).add_field(name="Middleman",
                                                                                         value=ctx.message.server.get_member(
                                                                                             data[id][
                                                                                                 "middlemanid"]).mention,
                                                                                         inline=False))
    data[id]["callmessageid"] = msg.id
    saveMM(data)
コード例 #23
0
async def rep(ctx, user: discord.Member = None, *, description: str = None):
    if not ctx.message.content.split(" ", 1)[0].startswith("!") and ctx.message.channel.id in permittedchannels:
        if ctx.message.author == user:
            await bot.say(embed=UsefulMethods.buildBaseEmbed(user, "Adding Rep", "You can't add reps to yourself!"))
            return
        if UsefulMethods.checkRepTime(ctx.message.author, user):
            UsefulMethods.addREP(ctx.message.content.split(" ", 1)[0], user, description, ctx.message.author)
            await bot.say(embed=UsefulMethods.buildBaseEmbed(ctx.message.author, "Adding Rep",
                                                             "Succesfully added to {0}'s profile. You can check your reps with `!rep`.".format(
                                                                 user.mention)))
        else:
            await bot.say(embed=UsefulMethods.buildBaseEmbed(ctx.message.author, "Adding Rep",
                                                             "You have to wait until {0} MEZ to post reps.".format(
                                                                 UsefulMethods.timeTillNextRep(ctx.message.author,
                                                                                               user))))
            pass
    if ctx.message.content.split(" ", 1)[0].startswith(
            "!") and ctx.message.channel.id in permittedchannels and description is None:
        if user is None:
            user = ctx.message.author
        await bot.say(embed=UsefulMethods.latestREPS(user))
コード例 #24
0
def leaderboard_mods(author, server=None):
    if server is None:
        server = author.server
    data = openJSON()

    all_stats = []
    for memberid in list(data):
        try:
            user = discord.utils.find(lambda u: u.id == memberid,
                                      server.members)

            for role in user.roles:
                if role.name.lower() == "moderators":
                    all_stats.append(stats(memberid))
        except:
            del data[memberid]
            print("deleted an user")
            saveJSON(data)

    i = 1
    while i < len(all_stats):
        if all_stats[i][1] > all_stats[i - 1][1]:
            help = all_stats[i]
            all_stats[i] = all_stats[i - 1]
            all_stats[i - 1] = help
            if not i == 1:
                i -= 1
        else:
            i += 1

    embed = UsefulMethods.buildBaseEmbed(author, "Activity Leaderboards")

    place = 1
    for x in all_stats:
        embed.add_field(name="{0}. Place: `{1}` (Total Points: {2})".format(
            place, discord.utils.find(lambda m: m.id == x[2], server.members),
            x[1]),
                        value=x[0],
                        inline=False)
        place += 1

    return embed
コード例 #25
0
async def call(bot, ctx, trade_partner, platform, description):
    if not ctx.message.channel.name == "middleman-call":
        await bot.send_message(ctx.message.author, embed=um.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                                           "You have to go to #middleman-call to call a middleman."))
        await bot.delete_message(ctx.message)

        return

    data = openMM()
    server = ctx.message.server
    tradeid = len(data)

    for i in range(len(data)):
        i = str(i)
        if data[i]["callerid"] == ctx.message.author.id and data[i][
            "active"]:
            msg = await bot.send_message(ctx.message.channel,
                                         embed=um.buildBaseEmbed(ctx.message.author, "Middleman System",
                                                                 "You are still in an open middleman call.").add_field(
                                             name="Trade {0}".format(i), value="\u200b  **Caller**: {0}\n"
                                                                               "  **Partner**: {1}\n"
                                                                               "  **Description**: {2}\n"
                                                                               "  **ID**: {3}".format(
                                                 ctx.message.server.get_member(
                                                     data[i][
                                                         "callerid"]).mention,
                                                 ctx.message.server.get_member(
                                                     data[i][
                                                         "partnerid"]).mention,

                                                 data[i]["description"], data[i]["id"])))
            await asyncio.sleep(15)
            for m in [msg, ctx.message]:
                await bot.delete_message(m)

            return
            # data.append("trade{}".format(len(data)))

    readperm = discord.PermissionOverwrite(read_messages=True)
    everyone = discord.PermissionOverwrite(read_messages=False)

    channel = await bot.create_channel(server, "trade{}".format(tradeid), (server.default_role, everyone),
                                       (ctx.message.author, readperm), (trade_partner, readperm),
                                       (ctx.message.server.get_member("213420388741283840"), readperm))

    data[str(tradeid)] = {
        "partnerid": trade_partner.id,
        "partnername": trade_partner.name,
        "callerid": ctx.message.author.id,
        "callername": ctx.message.author.name,
        "platform": platform,
        "description": description,
        "id": tradeid,
        "channelid": channel.id,
        "active": True,
        "middlemanname": None,
        "middlemanid": None,
        "confirmcaller": False,
        "confirmpartner": False,
        "creationtime": time.time(),
        "callmessageid": None
    }

    await bot.send_message(channel,
                           "Hey {0} and {1}, please confirm your trade `{2}` by typing !yes. You have 10 minutes until the trade gets deleted.".format(
                               ctx.message.author.mention, trade_partner.mention, description))
    await bot.delete_message(ctx.message)
    saveMM(data)
    await asyncio.sleep(600)

    print("open")
    data = openMM()

    if data[str(tradeid)]["confirmpartner"] == False or data[str(tradeid)][
        "confirmcaller"] == False:
        for u in [ctx.message.author, trade_partner]:
            await bot.send_message(u, "You were too slow, your trade `{0}` got deleted.".format(description))

        await bot.delete_channel(channel)

        del data[str(tradeid)]

        saveMM(data)
        print("deleted")
コード例 #26
0
async def repcooldown(ctx, user: discord.Member = None):
    if user is None:
        user = ctx.message.author
    await bot.say(embed=UsefulMethods.repcooldown(user))
コード例 #27
0
def inventory(author, bot):
    data = openJSONCheck(author.id, author)
    crates = data["crates"][author.id]

    # crate_balance = "\u200b  Mincoin: {}\n".format(crates["minicoin"])
    crate_balance = "\u200b"

    if crates["regular"] > 0:
        crate_balance += "\u200b  Regular Crates: {}\n".format(
            crates["regular"])
    if crates["golden"] > 0:
        crate_balance += "\u200b  Golden Crates: {}\n".format(crates["golden"])
    if crates["diamond"] > 0:
        crate_balance += "\u200b  Diamond Crates: {}\n".format(
            crates["diamond"])
    if crates["master"] > 0:
        crate_balance += "\u200b  Master Crates: {}\n".format(crates["master"])

    if crate_balance == "\u200b":
        # crate_balance = "You don't have any crates."
        embed = UsefulMethods.buildBaseEmbed(
            author, "{0}'s Inventory".format(author.name))
    else:
        print("Hier!", crate_balance)

        embed = UsefulMethods.buildBaseEmbed(
            author, "{0}'s Inventory".format(author.name), crate_balance)

    embed.add_field(name="Mincoin",
                    value="\u200b  {1} {0}\n".format(
                        UsefulMethods.getAnimatedEmoji(bot, "mincoin"),
                        crates["minicoin"]),
                    inline=False)

    for r in tiers:
        out = ""
        for item in crates["items"][r]:
            shiny = ""
            shiny_bool = False
            item_out = item
            if crates["items"][r][item]["shiny"]:
                shiny = "**S.**"
                shiny_bool = True
                item_out = item[2:]

            amount = crates["items"][r][item]["am"]
            for _r in author.roles:
                if _r.name.lower() == item_out.lower():
                    print(checkIfShiny(_r))
                    if checkIfShiny(_r) == shiny_bool:
                        amount -= 1
            if not amount == 0:
                out_add = "\n\u200b {2}{0} x{1}".format(
                    item_out.title(), amount, shiny)

                out += out_add
        if not out == "":
            embed.add_field(name="{} Roles".format(r.title()),
                            value=out,
                            inline=False)
    if out == "" and crate_balance == "":
        embed = UsefulMethods.buildBaseEmbed(
            author, "{0}'s Inventory".format(author.name),
            "This inventory is empty.")

    return embed
コード例 #28
0
async def reps(ctx, user: discord.Member, count=None):
    if ctx.message.content.split(" ", 1)[0].startswith("!") and ctx.message.channel.id in permittedchannels:
        if count == "all":
            count = 100
        await bot.say(embed=UsefulMethods.latestREPS(user, count))
コード例 #29
0
async def remove(bot, author, item):
    shiny = False
    if item.lower().startswith("s."):
        shiny = True
        item = item[2:]

    if not checkIfRoleExists(item) and not item.lower() == "all":
        return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                            "This role isn't equippable")

    if any(r.name.lower() == item.lower() for r in author.roles):
        data = openJSONCheck(author.id, author)
        ########### SHINY BUG #################
        if item.title() not in data["crates"][author.id]["items"][getRarity(
                item)]:
            addItemToInventory(
                item.title(), shiny,
                data["crates"][author.id]["items"][getRarity(item)])
            saveJSON(data)

    if item.lower() == "all":
        roles = ""
        for role in author.roles:
            for r in tiers:
                for i in items[r]:
                    print(role.name.lower(), i.lower())
                    if role.name.lower() == i.lower():
                        while role in author.roles:
                            await bot.remove_roles(author, role)
                        roles += role.name + ", "
        if roles == "":
            return UsefulMethods.buildBaseEmbed(
                author, "Crate System",
                "You don't have any roles equipped.".format(roles[:-2]))
        else:
            return UsefulMethods.buildBaseEmbed(
                author, "Crate System",
                "Succesfully removed {}.".format(roles[:-2]))

    if shiny:
        for r in author.roles:
            if r.name.lower() == item.lower():
                for p in r.permissions:
                    if ("change_nickname", True) == p:
                        await bot.remove_roles(author, r)

                        return UsefulMethods.buildBaseEmbed(
                            author, "Crate System",
                            "Succesfully removed {}".format(item.title()))
    else:
        for r in author.roles:
            if r.name.lower() == item.lower():
                for p in r.permissions:
                    if ("change_nickname", False) == p:
                        await bot.remove_roles(author, r)
                        return UsefulMethods.buildBaseEmbed(
                            author, "Crate System",
                            "Succesfully removed {}".format(item.title()))

    return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                        "You dont have this role equipped")
コード例 #30
0
async def burn(bot, channel, author, kwargs):
    args = kwargs.lower().split(" ")
    print(args[0])
    # rarity
    if args[0] in tiers:
        duplicates = get_duplicated_roles_by_rarity(author, args[0])
        out = ""
        minicoin = 0
        for item in duplicates:
            minicoin += burn_item(author, item, duplicates[item])
            out += str(duplicates[item]) + " " + item + ", "

        return UsefulMethods.buildBaseEmbed(
            author, "Crate System",
            "You successfully burned {} and got {} Mincoins.".format(
                out[:-2], minicoin))

    if args[0].startswith("all"):
        duplicates = get_all_duplicated_roles(author)
        out = ""
        minicoin = 0
        for item in duplicates:
            minicoin += burn_item(author, item, duplicates[item])
            out += str(duplicates[item]) + " " + item + ", "

        return UsefulMethods.buildBaseEmbed(
            author, "Crate System",
            "You successfully burned {} and got {} Mincoins.".format(
                out[:-2], minicoin))

    amount = None
    for s in (list(kwargs)):
        if s.isdecimal():
            if amount:
                amount += s
            else:
                amount = s

    kwargs = kwargs.replace("" if amount is None else amount,
                            "")[:(len(kwargs) if amount is None else -1)]
    print(kwargs + "A")

    if checkIfRoleExists(kwargs):
        if check_if_user_has_role(author, kwargs,
                                  2 if amount is None else int(amount)):

            minicoin = 0

            amount = (1 if amount is None else int(amount))

            minicoin += burn_item(author, kwargs,
                                  1 if amount is None else int(amount))
            out = str(amount) + " " + kwargs.title() + ", "

            if minicoin == 0:
                return UsefulMethods.buildBaseEmbed(
                    author, "Crate System", "You don't have multiple roles!")
            return UsefulMethods.buildBaseEmbed(
                author, "Crate System",
                "You successfully burned {} and got {} Mincoins.".format(
                    out[:-2], minicoin))
        else:
            am_warnung = ("once"
                          if amount is None else "{} times".format(amount))
            return UsefulMethods.buildBaseEmbed(
                author, "Crate System",
                "You don't have this role more than {}.".format(am_warnung))
    return UsefulMethods.buildBaseEmbed(author, "Crate System",
                                        "Invalid Arguments.")