Exemplo n.º 1
0
    def store_showcase_success(userID: discord.Member):
        from cogs.essential import check_user_has_role
        # log command execution
        print(Global_Log.command_run_without_exception('store showcase'))
        # create embed
        embed = discord.Embed(
            title=
            f":shopping_bags:   WELCOME TO THE {global_dialogue_var.storeName.upper()}!   :shopping_bags:",
            description=
            f"Here are displayed all the currently available-to-purchase items!",
            color=discord.Colour.random())
        # load data
        with open('main/assets/store_inv.json') as store_inv:
            store_inv = json.load(store_inv)

            for item in store_inv:
                disc_msg = ""
                price = int(store_inv[item]['price'])
                if check_user_has_role(userID, 804849555094765598):
                    disc_msg = f"(original price is {price} but a discount of 10% has been applied due to the role 'bon toutou')"
                    price = price - (price * discount)

                embed.add_field(
                    name=f"{store_inv[item]['icon']}   -   {item}",
                    value=
                    (f"*Buy it for* ***{price} {global_dialogue_var.currency}*** :coin:"
                     f"\n*{disc_msg}*"),
                    inline=False)

            return embed
Exemplo n.º 2
0
    async def bon_toutou(self, userID: discord.Member):
        from cogs.essential import check_user_has_role
        from cogs.essential import check_user_is_bot
        from cogs.background_tasks import Bon_Toutou_Task
        guild = self.client.get_guild(774048252848111636)
        role_bon_toutou = guild.get_role(804849555094765598)
        role_hold_time = (60 * 60) * 24

        if check_user_has_role(userID, 805897076437155861):
            print(Economy_Grind_Log.target_is_mauvais_toutou(userID))
            return await Bon_Toutou_Task.bon_toutou_assign(self)

        if check_user_is_bot(userID):
            print(Economy_Grind_Log.target_is_a_bot(userID))
            return await Bon_Toutou_Task.bon_toutou_assign(self)

        if check_vault(userID) is False:
            print(Economy_Grind_Log.target_is_not_registered(userID))
            return await Bon_Toutou_Task.bon_toutou_assign(self)

        if check_former_bon_toutou(userID):
            print(Economy_Grind_Log.target_is_former_bt(userID))
            return await Bon_Toutou_Task.bon_toutou_assign(self)

        md_bon_toutou_status(userID)
        #await userID.send(Economy_Grind_Dialogue.bon_toutou_success(userID))
        await userID.add_roles(role_bon_toutou)

        await asyncio.sleep(role_hold_time)

        await userID.remove_roles(role_bon_toutou)
Exemplo n.º 3
0
    async def item_mauvais_toutou(ctx, target: discord.Member, item: str):
        # get the functions from the cog inventory, essential and economy
        from cogs.inventory import remove_item_from_inv 
        from cogs.essential import check_user_has_role
        from cogs.essential import check_user_is_bot
        from cogs.economy import check_vault
        
        # set the roles 'mauvais toutou' and 'bon toutou' /// Also decide how long the 'mauvais toutou' role is given. 24 hours here.
        role_mauvais_toutou = ctx.guild.get_role(805897076437155861)
        role_bon_toutou = ctx.guild.get_role(804849555094765598)
        role_hold_time = (60*60)*24

        # check if user already has role 'mauvais toutou'
        if check_user_has_role(target, 805897076437155861):
            return await ctx.reply(Item_Dialogue.item_mauvais_toutou("target_already_has_role", target))
        
        # check if user is a bot
        if check_user_is_bot(target):
            return await ctx.reply(Item_Dialogue.item_mauvais_toutou("target_is_bot", target))
        
        # check if user has a vault
        if check_vault(target) is False:
            return await ctx.reply(Item_Dialogue.item_mauvais_toutou("target_is_not_registered", target))
        
        # remove the used item from the inventory of the author
        remove_item_from_inv(ctx.author, item, 1)
        # add the role to the target and remove the 'bon toutou' role if he had it
        await target.add_roles(role_mauvais_toutou)
        if check_user_has_role(target, 804849555094765598):
            await target.remove_roles(role_bon_toutou)
        # send success dialogue & logs
        print(f'\t{log_format.INFO} {ctx.author} SUCCESSFULLY USED THE ITEM Mauvais toutou! ON {target}.{log_format.END}')
        await ctx.reply(Inventory_Dialogue.use_success("item_used", target, item, ctx.author))

        # wait for the role hold time to expire
        await asyncio.sleep(role_hold_time)
        # after role hold time, remove role 'mauvais toutou'
        return await target.remove_roles(role_mauvais_toutou)
Exemplo n.º 4
0
    def passive_income_stack(self, ctx, userID: discord.Member):
        from cogs.essential import check_user_has_role
        from cogs.essential import malus_rate
        from cogs.essential import bonus_rate

        userID = str(userID)
        with open('./main/assets/vault.json') as vault:
            vault = json.load(vault)
            stack = vault[userID]["reward"]["passive_income_stack"]
            reward = stack + stockmarket_rate(stack)

            # add malus rate to the prize if user is 'mauvais toutou'
            if check_user_has_role(ctx.author, 805897076437155861):
                reward = stack - stack * malus_rate
            # add bonus rate to the prize if user is 'bon toutou'
            if check_user_has_role(ctx.author, 804849555094765598):
                reward = stack * bonus_rate

            vault[userID]["balance"] += reward
            vault[userID]["reward"]["passive_income_stack"] = 0
            edit_vault(vault)
            return Economy_Grind_Dialogue.stack_success(
                ctx.author, stack, reward)
Exemplo n.º 5
0
    def daily_reward(self, ctx, userID: discord.Member):
        from cogs.essential import check_user_has_role
        from cogs.essential import malus_rate
        from cogs.essential import bonus_rate

        with open('./main/assets/vault.json') as vault:
            vault = json.load(vault)
            now = datetime.now()
            date_now = now.strftime("%Y-%m-%d")
            reward = 1000

            userID = str(userID)
            dlr_claim = vault[userID]["reward"]["daily_reward_claim_date"]

            # add malus rate to the prize if user is 'mauvais toutou'
            if check_user_has_role(ctx.author, 805897076437155861):
                reward = reward - reward * malus_rate
            # add bonus rate to the prize if user is 'bon toutou'
            if check_user_has_role(ctx.author, 804849555094765598):
                reward = reward * bonus_rate

            if dlr_claim == False:
                vault[userID]["reward"]["daily_reward_claim_date"] = date_now
                vault[userID]["balance"] += reward
                edit_vault(vault)
                return Economy_Grind_Dialogue.daily_reward_success(
                    userID, reward, "first_claim")

            if dlr_claim < date_now:
                vault[userID]["reward"]["daily_reward_claim_date"] = date_now
                vault[userID]["balance"] += reward
                edit_vault(vault)
                return Economy_Grind_Dialogue.daily_reward_success(
                    userID, reward, "claim_success")

            return Economy_Grind_Dialogue.daily_reward_success(userID, reward)
Exemplo n.º 6
0
def store_buy_item(userID, query: str, price: int):
    # import functions from economy
    from cogs.economy import check_vault, get_balance, md_balance
    from cogs.essential import check_user_has_role, discount
    # check if user has role
    if check_user_has_role(userID, 804849555094765598):
        price = price - (price * discount)
# buy item 'A la niche'
    if query == 'A la niche!':
        if check_vault(userID) == False:
            # return if user is not registered
            return Global_Dialogue.user_not_registered('store buy')
        if get_balance(userID) < price:
            # return if user has not enough money
            return Global_Dialogue.user_cant_pay('store buy')
        # purchase is successful, pay the item
        md_balance(userID, "sub", price)
        add_item_to_inv(userID, "A la niche!", 1)
        return Store_Dialogue.store_purchase_complete(str(query))
# buy item 'Mauvais toutou'
    if query == 'Mauvais toutou!':
        if check_vault(userID) == False:
            # return if user is not registered
            return Global_Dialogue.user_not_registered('store buy')
        if get_balance(userID) < price:
            # return if user has not enough money
            return Global_Dialogue.user_cant_pay('store buy')
        # purchase is successful, pay the item
        md_balance(userID, "sub", price)
        add_item_to_inv(userID, "Mauvais toutou!", 1)
        return Store_Dialogue.store_purchase_complete(str(query))
# buy item 'Shush'
    if query == 'Shush!':
        if check_vault(userID) == False:
            # return if user is not registered
            return Global_Dialogue.user_not_registered('store buy')
        if get_balance(userID) < price:
            # return if user has not enough money
            return Global_Dialogue.user_cant_pay('store buy')
        # purchase is successful, pay the item
        md_balance(userID, "sub", price)
        add_item_to_inv(userID, "Shush!", 1)
        return Store_Dialogue.store_purchase_complete(str(query))

    return Global_Dialogue.query_exit('unknown_ID', 'store', userID)
Exemplo n.º 7
0
async def load(ctx, cog: str):
    from cogs.essential import check_user_has_role
    # check if user has permissions to use the command
    if check_user_has_role(ctx.author, ADMIN_ROLE_ID):
        return print(Global_Log.command_has_been_used(
            'load', ctx.author)), await ctx.reply(
                Global_Dialogue.user_not_allowed('load', ctx.author))
    # if conditions are met, try to execute
    try:
        client.load_extension(cog)
        edit_cog_list(cog, "load")
        return await ctx.reply(
            Main_Dialogue.load_command_success(cog, ctx.author))
    # if cog already loaded, return this exception
    except ExtensionAlreadyLoaded:
        return await ctx.reply(
            Main_ErrorHandler.load_error_cog_already_loaded(cog, ctx.author))
    # if cog does not exist, return this exception
    except ExtensionNotFound:
        return await ctx.reply(
            Main_ErrorHandler.load_error_cog_doesnt_exist(cog, ctx.author))
Exemplo n.º 8
0
async def coglist(ctx):
    from cogs.essential import check_user_has_role
    # check if user has permissions to use the command
    try:
        if check_user_has_role(ctx.author, ADMIN_ROLE_ID):
            return print(
                Global_Log.command_has_been_used(
                    'coglist', ctx.author)), await ctx.reply(
                        Global_Dialogue.user_not_allowed(
                            'coglist', ctx.author))
    except AttributeError:
        return print(Global_Log.command_has_been_used(
            'coglist', ctx.author)), await ctx.author.send(
                Global_Dialogue.command_executed_in_dm('coglist', ctx.author))
    # fecth the cogs json file and edit get its data
    with open('./main/assets/cogs.json') as cogs:
        cog_file = json.load(cogs)
        cog_dict = dict(cog_file["COGS"])
        cog_list = []
        # add a icon green or red depending on the status of the cog.
        for cog in cog_dict:
            if cog_dict[cog] == True:
                cog = f':green_circle:  **{cog}**'
                cog_list.append(cog)
            else:
                cog = f':red_circle:  **{cog}**'
                cog_list.append(cog)
        cog_list = '\n\n '.join(cog_list)
    # create the embed
    embed = discord.Embed(title="Cogs list", color=discord.Colour.random())
    embed.add_field(name="Here is the list of all the cogs.",
                    value=f'\n{cog_list}')
    # return the result of the command.
    return Main_Dialogue.cl_command_success(
        ctx.author), await ctx.message.add_reaction(
            dialogue_icon.dm), await ctx.author.send(embed=embed)
Exemplo n.º 9
0
    async def coinflip(self, ctx, amount: int):
        print(Global_Log.command_has_been_used('coinflip', ctx.author))
        from cogs.essential import check_user_has_role
        from cogs.essential import malus_rate
        from cogs.essential import bonus_rate

        amount = abs(amount)
        cf_prize = amount * 2
        coin_faces = ["head", "tail"]

        if check_vault(ctx.author) is False:
            return await ctx.reply(
                Global_Dialogue.user_not_registered('coinflip'))

        if get_balance(ctx.author) < amount:
            return await ctx.reply(Global_Dialogue.user_cant_pay('coinflip'))

        # add malus rate to the prize if user is 'mauvais toutou'
        if check_user_has_role(ctx.author, 805897076437155861):
            cf_prize = cf_prize - cf_prize * malus_rate
            print(cf_prize)
        # add bonus rate to the prize if user is 'bon toutou'
        if check_user_has_role(ctx.author, 804849555094765598):
            cf_prize = cf_prize * bonus_rate
            print(cf_prize)

        await ctx.send(
            Economy_Grind_Dialogue.coinflip_success(amount, ctx.author,
                                                    "cf_init"))
        print(Global_Log.bot_is_waiting_for_query(ctx.author))

        def check(ans):
            return ans.channel == ctx.channel and ans.author == ctx.author

        print(Global_Log.bot_is_waiting_for_query(ctx.author))
        ans = await self.client.wait_for('message', check=check)

        if ans.content.lower() != 'tail' and ans.content.lower() != 'head':
            return await ctx.reply(
                Economy_Grind_ErrorHandler.coinflip_error(
                    "fail_ans", ctx.author))

        guess = ans.content.lower()
        cf_result = random.choice(coin_faces)

        # if str(author) == bully:
        #     while guess == cf_result:
        #         cf_result = random.choice(coin_faces)

        await ctx.send(f'And the result is...')
        await asyncio.sleep(1)
        await ctx.send(f'**{cf_result}**! :coin:')
        await asyncio.sleep(1)

        if cf_result != guess:
            md_balance(ctx.author, "sub", amount)
            return await ctx.send(
                Economy_Grind_Dialogue.coinflip_success(
                    amount, ctx.author, "cf_lose"))

        md_balance(ctx.author, "add", cf_prize)
        return await ctx.send(
            Economy_Grind_Dialogue.coinflip_success(cf_prize, ctx.author,
                                                    "cf_win"))