Beispiel #1
0
 async def _close_rpg(self, ctx: commands.Context):
     mbr_data: dict = checkin_member(ctx.author)
     if mbr_data is not None:
         if "MAX-STAT" in mbr_data:
             emb = discord.Embed(title="Close Progress?",
                 description="Are you sure you want to close your current progress?\n"
                     "> Warning! This may delete all of your RPG attribute like items, equipments, stats, and moves you have learned.",
                 colour=discord.Colour(WHITE))
             emb.set_footer(text="React ✅ to continue or ❌ to abort")
             hm: discord.Message = await ctx.send(embed=emb)
             await hm.add_reaction("✅")
             await hm.add_reaction("❌")
             try:
                 r, u = await self.bot.wait_for(event= "reaction_add", timeout= 30.0, check= lambda reaction, user: True if (str(reaction.emoji) == "❌" or str(reaction.emoji) == "✅") and user == ctx.author else False)
                 await hm.delete()
                 if str(r.emoji) == "✅":
                     hm = await ctx.send("*Deleting your progress, Wait for a moment.*")
                     rpg_close(ctx.author)
                     emb = discord.Embed(title= f"⚰️ RIP | {ctx.author.name}", colour=WHITE)
                     emb.set_image(url="https://trello-attachments.s3.amazonaws.com/5ee1ce52bb089c7be29e6b4f/5efc6fe38c338f1f7b4799a8/ef81e5b6732bcdc5cd6eebe093486a31/Coffin_Dance_GIF.gif")
                     await ctx.send(embed=emb)
                 else:
                     await ctx.send("*Aborted*")
             except asyncio.TimeoutError:
                 await hm.delete()
                 await ctx.send("*Request Timeout*")
         else:
             await ctx.send(f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__")
Beispiel #2
0
    async def ore_inventory(self, message: discord.Message,
                            person: discord.User):
        """Only for Inventory."""
        # Get Member Data
        user_data = checkin_member(person)
        if user_data is not None:
            user_sack: dict = user_data["backpack"]["ores"]
            pick_level: int = user_data["backpack"]["pickaxe-level"]

            # Get Detail Sack of Ores
            ore_keys: list = list(
                pickaxe_identity[pick_level]["balance"].keys())
            description_bag: str = ""
            for i in range(len(ore_keys)):
                ore_name: str = ore_keys[i]
                if i == len(ore_keys) - 1:
                    description_bag += f"`{ore_name}` : {user_sack[ore_name]} | **{pickaxe_identity[pick_level]['balance'][ore_name] / 100}%**"
                else:
                    description_bag += f"`{ore_name}` : {user_sack[ore_name]} | **{pickaxe_identity[pick_level]['balance'][ore_name] / 100}%**\n"

            # Edit Menu with This Data Detail
            emb = discord.Embed(
                title=f"💎 {person.display_name}'s' Sack Of Ores",
                description=f"Pickaxe Level : {pick_level}\n"
                f"{description_bag}",
                colour=WHITE)
            emb.set_thumbnail(
                url=
                "https://webstockreview.net/images/coal-clipart-bag-coal-6.png"
            )
            emb.set_footer(
                text=
                f"You can upgrade your pickaxe by using {get_prefix(message.guild)}pickaxeup"
            )
            await message.edit(embed=emb)
Beispiel #3
0
    async def _rpg_nature(self, ctx: commands.Context, *args):
        mbr_data = checkin_member(ctx.author)
        if mbr_data is not None:
            if "CHARID" in mbr_data:
                if len(args) == 0:
                    await self._nature_help(ctx.channel)
                else:
                    # Get Info
                    if args[0].lower() == "info" or args[0].lower() == "-i":
                        pass

                    # Change Nature
                    elif is_number(args[0]):
                        if int(args[0]) > len(self.NATURES) or int(
                                args[0]) <= 0:
                            return
                        else:
                            if mbr_data['CHARID'] == int(args[0]):
                                await ctx.send(
                                    content=
                                    f"*You are already in class {self.NATURES[int(args[0])]}*"
                                )
                            else:
                                db_mbr.SetObject(
                                    {"member_id": str(ctx.author.id)},
                                    {'CHARID': int(args[0])})
                                await ctx.send(
                                    content=
                                    f"*You have changed from {self.NATURES[mbr_data['CHARID']]} to {self.NATURES[int(args[0])]}.*"
                                )
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__"
                )
Beispiel #4
0
    async def _battle(self, ctx: commands.Context, *args):
        mbr_data = checkin_member(ctx.author)
        if mbr_data is not None:
            if "PRIM-STAT" in mbr_data:
                if len(args) == 0:
                    await self.print_help(ctx.channel)
                else:
                    if ctx.channel.id in self.cooldown:
                        hm: discord.Message = await ctx.send(
                            f"*Battle in Progress in this Channel. ({ctx.channel.name})*"
                        )
                        await asyncio.sleep(3)
                        await hm.delete()
                        await ctx.message.delete()
                    else:
                        self.cooldown.append(ctx.channel.id)

                        # 1 vs 1 Battle
                        if args[0].lower() == "1v1":
                            await self._queue(ctx.channel, 2)

                        # 2 vs 2 Battle
                        elif args[0].lower() == "2v2":
                            await self._queue(ctx.channel, 4)

                        # 3 vs 3 Battle
                        elif args[0].lower() == "3v3":
                            await self._queue(ctx.channel, 6)
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild.id)}start to begin.**__"
                )
 async def _learned_moves(self, ctx: commands.Context):
     mbr_data = checkin_member(ctx.author)
     if mbr_data is not None:
         if "moves" in mbr_data:
             char_player = checkClassID(ctx.author)
             emb = discord.Embed(title=f"{char_player.name} Move")
             normal_detail: dict = char_player._normal_move.GetDetail
             custom_detail: list = [
                 n.GetDetail for n in char_player._custom_moves
             ]
             emb = discord.Embed(title="Learned Moves", colour=WHITE)
             emb.add_field(
                 name=f"Normal Move: {normal_detail['Name']}",
                 inline=False,
                 value=f"Type Attack: {normal_detail['Type Attack'][1]}\n"
                 f"Element: {normal_detail['Element'][1]}\n"
                 f"Target: {normal_detail['Target'][1]}\n"
                 f"Required Mana: {normal_detail['Required Mana']}")
             for i in range(len(custom_detail)):
                 emb.add_field(
                     name=f"Custom Move {i+1}: {custom_detail[i]['Name']}",
                     inline=False,
                     value=
                     f"Type Attack: {custom_detail[i]['Type Attack'][1]}\n"
                     f"Element: {custom_detail[i]['Element'][1]}\n"
                     f"Target: {custom_detail[i]['Target'][1]}\n"
                     f"Required Mana: {custom_detail[i]['Required Mana']}")
             await ctx.send(embed=emb)
         else:
             await ctx.send(
                 f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__"
             )
    async def _reset_skill(self, ctx: commands.Context):
        mbr_data: dict = checkin_member(ctx.author)
        if mbr_data is not None:
            if "PRIM-STAT" in mbr_data:
                # Send Hint
                menus: list = ["✅", "❌"]
                emb = discord.Embed(
                    title="Reset your Skills?",
                    description="Are you sure you want to reset your skills?\n"
                    "> It will reset all your primary stat like Strength, Endurance, and etc to Zero. However it will refund all your skillpoint.",
                    colour=WHITE)
                emb.set_footer(text="React ✅ to continue or ❌ to abort")
                hm: discord.Message = await ctx.send(embed=emb)
                for i in menus:
                    await hm.add_reaction(i)

                try:
                    # Waiting for Response
                    r: discord.Reaction
                    u: discord.User
                    r, u = await self.bot.wait_for(
                        event="reaction_add",
                        check=lambda reaction, user: True
                        if str(reaction.emoji
                               ) in menus and user == ctx.author else False,
                        timeout=30.0)
                    await hm.delete()

                    # Proceed
                    if str(r.emoji) == "✅":
                        hm = await ctx.send(
                            "*Resetting your Stat, Wait for a moment.*")
                        skill_set: int = 0
                        for skill in mbr_data["PRIM-STAT"]:
                            temp_amo: int = mbr_data['PRIM-STAT'][skill]
                            skill_set += temp_amo
                            db_mbr.SetObject(
                                {"member_id": mbr_data['member_id']},
                                {f'PRIM-STAT.{skill}': 0})
                        db_mbr.SetObject({"member_id": mbr_data['member_id']},
                                         {"skill-point": mbr_data['LVL']})
                        await hm.delete()
                        await ctx.send(embed=discord.Embed(
                            title=
                            f"{ctx.author.name} has reset his/her Skills. Refunded {skill_set} Skillpoint(s)",
                            colour=WHITE))

                    # Abort
                    else:
                        await ctx.send("*Aborted*")

                except asyncio.TimeoutError:
                    await hm.delete()
                    await ctx.send("*Request Timeout*")
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild.id)}start to begin.**__"
                )
Beispiel #7
0
 async def detail_money(self, message: discord.Message,
                        person: discord.User):
     gdata: dict = checkin_guild(message.guild)
     mbr_data = checkin_member(person)
     if mbr_data is not None:
         emb = discord.Embed(
             description=
             f"> 👛 Amount : {mbr_data['backpack']['money'][str(message.guild.id)]} {gdata['currency']['type']}",
             colour=WHITE)
         emb.set_author(name=person.name, icon_url=person.avatar_url)
         await message.edit(embed=emb)
    async def _make_things(self, ctx: commands.Context, *args):
        """## Arguments
        ------------
        Insert with the following order: `option`(str) `name`(str). It is optional.

        ## Options
        ----------
        Move, Item, Equipment
        """
        mbr_data = checkin_member(ctx.author)
        if mbr_data is not None:
            if "moves" in mbr_data:
                if len(args) == 0:
                    await self.__creator_help(ctx.channel)
                elif len(args) >= 1:
                    gld_data: dict = checkin_guild(ctx.guild)
                    if args[0].lower() == "move" or args[0].lower() == "m":
                        if len(gld_data["shop"]
                               ["movements"]) >= gld_data["max-misc"]["move"]:
                            await ctx.send(
                                "Server already contain full Custom Move. You can't create unless delete one of them."
                            )
                        else:
                            await self.__make_move_process(ctx.channel,
                                                           ctx.author,
                                                           name=" ".join(
                                                               args[1:]))
                    elif args[0].lower() == "item" or args[0].lower() == "i":
                        if len(gld_data["shop"]["equipments"]
                               ) >= gld_data["max-misc"]["equip"]:
                            await ctx.send(
                                "Server already contain full Custom Move. You can't create unless delete one of them."
                            )
                        else:
                            await self.__make_item_process(ctx.channel,
                                                           ctx.author,
                                                           name=" ".join(
                                                               args[1:]))
                    elif args[0].lower() == "equipment" or args[0].lower(
                    ) == "eq":
                        if len(gld_data["shop"]
                               ["items"]) >= gld_data["max-misc"]["item"]:
                            await ctx.send(
                                "Server already contain full Custom Move. You can't create unless delete one of them."
                            )
                        else:
                            await self.__make_eq_process(ctx.channel,
                                                         ctx.author,
                                                         name=" ".join(
                                                             args[1:]))
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__"
                )
Beispiel #9
0
 async def _start_rpg(self, ctx: commands.Context):
     mbr_data = checkin_member(ctx.author)
     if mbr_data is not None:
         if "MAX-STAT" in mbr_data:
             await ctx.send(f"__**{ctx.author.name}, You have already start your character, type {get_prefix(ctx.guild)}stat to see your current progress.**__")
         else:
             async with ctx.typing():
                 hm: discord.Message = await ctx.send("*Building your character, this might take a seconds.*")
                 rpg_init(ctx.author)
                 emb = discord.Embed(title=f"👱‍♂️ Character has been Created", colour=WHITE, 
                                     description=f"Welcome {ctx.author.name}! Check your stat in {get_prefix(ctx.guild)}stat")
                 await hm.delete()
             await ctx.send(embed=emb)
Beispiel #10
0
def rpg_close(user: discord.User):
    mbr_data: dict = checkin_member(user)
    default_data: dict = start_rpg
    for el in default_data:
        subdata = None
        dlist: list = el.split(".")
        for n in dlist:
            if subdata is None:
                subdata = mbr_data[n]
            else:
                subdata = subdata[n]
        default_data[el] = subdata
    db_mbr.UnsetItem({"member_id": mbr_data["member_id"]}, default_data)
Beispiel #11
0
    async def _dig(self, ctx):
        person: discord.User = ctx.author
        user_bag = checkin_member(person)
        if user_bag is not None:
            # Digging Animation
            dig = "Dig... "
            emb = discord.Embed(title="⛏️ Mining...",
                                description=dig,
                                colour=WHITE)
            queing: discord.Message = await ctx.send(embed=emb)
            await asyncio.sleep(0.5)
            for i in range(2):
                dig += "Dig... "
                emb = discord.Embed(title="⛏️ Mining...",
                                    description=dig,
                                    colour=WHITE)
                await queing.edit(embed=emb)
                await asyncio.sleep(0.5)

            # Getting an Ore
            ore: str = self.rarity_randomize(
                user_bag["backpack"]["pickaxe-level"])
            failed = [
                "It's just a Rock... Throw it away!",
                "Punching rock is hard, did you realize you forgot your pickaxe?",
                "OMG Ghost! RUN!!!",
                "You went into the Lava, I told you not to dig straight down :v"
            ]

            # Print Out Result
            if ore is None:
                emb = discord.Embed(title="💨 Better Luck Next Time...",
                                    description=f"{random.choice(failed)}",
                                    colour=WHITE)
                await queing.edit(embed=emb)
            else:
                emb = discord.Embed(
                    title="💎 Bling!",
                    description=
                    f"Yay {person.name}, You have got __**{ore}**__!",
                    colour=WHITE)
                emb.set_footer(
                    text=
                    f"Check {get_prefix(ctx.guild)}ore to see your collection."
                )
                await queing.edit(embed=emb)
                db_mbr.IncreaseItem({"member_id": str(person.id)},
                                    {f"backpack.ores.{ore}": 1})  # Save Data
Beispiel #12
0
    async def _profile(self, ctx: commands.Context, *args):
        # Inner Function
        def get_age(start: datetime.datetime, end: datetime.datetime) -> str:
            days = (end - start).days
            years = days // 365
            months = (days - (years * 365)) // 30
            days = days - (years * 365) - (months * 30)
            return f"{years}Y {months}M {days}D"

        # Get Player ID
        person: discord.User
        if len(args) == 0:
            person = ctx.message.author
        elif "@!" in args[0]:
            person_id = int(args[0].split('!')[1].split('>')[0])
            person = await self.bot.fetch_user(person_id)

        # Check if it is a Bot, not Member
        if person.bot is True:
            return

        # Print Out Profile Information
        async with ctx.typing():
            user_title: str = checkin_member(person)["title"]
            roles: list = [
                role for role in ctx.guild.roles if role in ctx.author.roles
            ]
            role_desc: str = " ".join([f"`{rm.name}`" for rm in roles])
            emb = discord.Embed(title=f"📜 Profile | {person.name}",
                                colour=WHITE)
            emb.add_field(
                name="Identity :",
                value=f"Title: __**{user_title}**__\n"
                f"Nick: **{ctx.author.nick if ctx.author.nick is not None else person.name}**\n"
                f"ID: `{person.id}`",
                inline=False)
            emb.add_field(
                name="Information :",
                value=f"Current Activity: `{ctx.author.activity}`\n"
                f"Created At: `{person.created_at.strftime('%B %d %Y')}`\n"
                f"Joined Server: `{person.joined_at.strftime('%B %d %Y')}`\n"
                f"Account Age: `{get_age(person.created_at, datetime.datetime.now())}`\n"
                f"Highest Role: `{person.top_role}`",
                inline=False)
            emb.add_field(name="Roles :", value=role_desc, inline=False)
            emb.set_thumbnail(url=person.avatar_url)
        await ctx.send(embed=emb)
 async def _stat(self,
                 ctx: commands.Context,
                 *,
                 person: discord.Member = None):
     person = ctx.author if person is None else person
     mbr_data = checkin_member(person)
     if mbr_data is not None:
         if "PRIM-STAT" in mbr_data:
             async with ctx.typing():
                 image_name: str = self.generate_stat_image(
                     person, mbr_data)
                 stat: Player = checkClassID(person)
                 emb = discord.Embed(
                     title=mbr_data['title'],
                     description=f"`CLASS` : {stat.ClassName}\n",
                     colour=WHITE)
                 emb.add_field(
                     name="Skill Stat",
                     value=
                     f"`Strength` : {mbr_data['PRIM-STAT']['STR']} / {MAXSKILL}\n"
                     f"`Endurance` : {mbr_data['PRIM-STAT']['END']} / {MAXSKILL}\n"
                     f"`Agility` : {mbr_data['PRIM-STAT']['AGI']} / {MAXSKILL}\n"
                     f"`Focus` : {mbr_data['PRIM-STAT']['FOC']} / {MAXSKILL}\n"
                     f"`Intelligence` : {mbr_data['PRIM-STAT']['ITE']} / {MAXSKILL}\n"
                     f"`Wise` : {mbr_data['PRIM-STAT']['WIS']} / {MAXSKILL}",
                     inline=True)
                 emb.add_field(
                     name="Substat",
                     value=f"`HP`: {stat.HP} | `Mana`: {stat.MANA}\n"
                     f"`DEF`: {stat.DEF} | `Magic DEF`: {stat.MDEF}\n"
                     f"`ATT`: {stat.ATT} | `Magic ATT`: {stat.MATT}\n"
                     f"`SPD`: {stat.SPD}\n"
                     f"`Critical Chance`: {stat.CRIT}%",
                     inline=True)
                 emb.set_author(name=person.nick
                                if person.nick is not None else person.name,
                                icon_url=person.avatar_url)
             with open(f"./{image_name}", 'rb') as f:
                 await ctx.send(embed=emb,
                                file=discord.File(f, filename=image_name))
                 f.close()
             if os.path.exists(image_name):
                 os.remove(image_name)
         else:
             await ctx.send(
                 f"__**{person.name}, You haven't start your character, type {get_prefix(ctx.guild.id)}start to begin.**__"
             )
Beispiel #14
0
    async def _pickaxeup(self, ctx: commands.Context):
        # Initialize Things
        able_upgrade: bool = True
        user_data = checkin_member(ctx.author)
        if user_data is not None:
            sack_of_ores: dict = user_data["backpack"]["ores"]
            pick_level: int = user_data["backpack"]["pickaxe-level"]
            requirement: dict = pickaxe_identity[pick_level + 1]["requirement"]
            list_required: list = list(requirement.keys())

            # Check if it is Able to Upgrade
            req_text: str = ""
            for i in range(len(list_required)):
                if sack_of_ores[list_required[i]] < requirement[
                        list_required[i]]:
                    able_upgrade = False
                if i == len(list_required) - 1:
                    req_text += f"> `{list_required[i]}`: {sack_of_ores[list_required[i]]}/{requirement[list_required[i]]}"
                else:
                    req_text += f"> `{list_required[i]}`: {sack_of_ores[list_required[i]]}/{requirement[list_required[i]]}\n"

            # Print Out Requirements and Confirmation
            emb = discord.Embed(title=f"Upgrade to Level {pick_level + 1} ⛏️?",
                                description=f"**Requirements** : \n{req_text}",
                                colour=WHITE)
            if not able_upgrade:
                emb.set_footer(text="Sorry, Not Enough Materials.")
                await ctx.send(embed=emb)
            else:
                menus: list = ["✅", "❌"]
                emb.set_footer(
                    text="Will you Upgrade it? add ✅ to proceed or ❌ to abort")
                hm: discord.Message = await ctx.send(embed=emb)
                for i in menus:
                    await hm.add_reaction(i)
                try:
                    r: discord.Reaction
                    u: discord.User
                    r, u = await self.bot.wait_for(
                        event="reaction_add",
                        check=lambda reaction, user: True
                        if str(reaction.emoji
                               ) in menus and user == ctx.author else False,
                        timeout=30.0)
                    if str(r.emoji) == "✅":
                        await hm.delete()
                        emb = discord.Embed(
                            title=
                            f"Your ⛏️ has been Upgraded to level {pick_level + 1}",
                            description=f"See the Stat in g.inv",
                            colour=WHITE)
                        await ctx.send(embed=emb)
                        db_mbr.IncreaseItem({"member_id": str(ctx.author.id)},
                                            {"backpack.pickaxe-level": 1})
                        for ore in requirement:
                            db_mbr.IncreaseItem(
                                {"member_id": str(ctx.author.id)},
                                {f"backpack.ores.{ore}": -requirement[ore]})
                    else:
                        emb.set_footer(text="Ok, Next Time!")
                        await hm.edit(embed=emb)
                except asyncio.TimeoutError:
                    pass
    async def _skill_add(self, ctx: commands.Context, *args):
        mbr_data: dict = checkin_member(ctx.author)
        if mbr_data is not None:
            if "PRIM-STAT" in mbr_data:
                if len(args) == 0:
                    await self.print_skill_add_help(ctx.channel)
                else:
                    amount: int = 1  # Skill Amount
                    get_skill: str = ""
                    which: str = ""

                    # Choose Ability
                    if args[0].lower() == "str" or args[0].lower(
                    ) == "strength":
                        which = "Strength"
                        get_skill = "STR"
                    elif args[0].lower() == "end" or args[0].lower(
                    ) == "endurance":
                        which = "Endurance"
                        get_skill = "END"
                    elif args[0].lower() == "agi" or args[0].lower(
                    ) == "agility":
                        which = "Agility"
                        get_skill = "AGI"
                    elif args[0].lower() == "foc" or args[0].lower(
                    ) == "focus":
                        which = "Focus"
                        get_skill = "FOC"
                    elif args[0].lower() == "ite" or args[0].lower(
                    ) == "intelligence":
                        which = "Intelligence"
                        get_skill = "ITE"
                    elif args[0].lower() == "wis" or args[0].lower() == "wise":
                        which = "Wise"
                        get_skill = "WIS"
                    else:
                        return

                    skill_lvl: int = mbr_data["PRIM-STAT"][get_skill]
                    if len(args) >= 2:
                        if is_number(args[1]) is True:
                            amount = int(args[1])

                    # Check if Able to Upgrade
                    if mbr_data["skill-point"] < amount:
                        emb = discord.Embed(
                            title="Not Enough Skillpoint",
                            description=
                            f"You currently have {mbr_data['skill-point']} and it is not enough.",
                            colour=WHITE)
                        await ctx.send(embed=emb)
                    elif skill_lvl + amount > MAXSKILL:
                        emb = discord.Embed(
                            title="Skill Max Exceeded",
                            description=
                            f"You can't upgrade your {which} to {skill_lvl} / {MAXSKILL}",
                            colour=WHITE)
                        await ctx.send(embed=emb)

                    # Upgrade Skill
                    else:
                        db_mbr.IncreaseItem(
                            {"member_id": mbr_data["member_id"]}, {
                                "skill-point": -amount,
                                f"PRIM-STAT.{get_skill}": amount,
                            })
                        emb = discord.Embed(
                            title=
                            f"You have upgraded your {which} to {skill_lvl + amount} / {MAXSKILL}",
                            colour=WHITE)
                        await ctx.send(embed=emb)
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild.id)}start to begin.**__"
                )
Beispiel #16
0
def rpg_init(user: discord.User):
    mbr_data: dict = checkin_member(user)
    db_mbr.SetObject({"member_id": mbr_data["member_id"]}, start_rpg)
Beispiel #17
0
    async def _queue(self, channel: discord.TextChannel, player_count: int):
        # Send Hint
        teams: list = ["🔴", "🔵"]
        async with channel.typing():
            team1, team2 = [], []
            max_pcount: int = player_count // 2
            emb = discord.Embed(title="⌛ Waiting for Other Player to Join...",
                                description=f"{max_pcount}v{max_pcount} mode",
                                colour=WHITE)
            emb.add_field(name="🔴 Red Team",
                          value="```Empty Room```",
                          inline=False)
            emb.add_field(name="🔵 Blue Team",
                          value="```Empty Room```",
                          inline=False)
            emb.set_footer(text="React to Join One of the Team 🔴 🔵")
        hm: discord.Message = await channel.send(embed=emb)
        for i in teams:
            await hm.add_reaction(i)

        # Edit Hint and Wait for User process
        try:
            while True:
                # Wait for Reaction Reply
                r, u = await self.bot.wait_for(
                    event="reaction_add",
                    timeout=60.0,
                    check=lambda reaction, user: True
                    if str(reaction.emoji
                           ) in teams and user.bot is False else False)

                # Check if user has already registered
                mbr_data = checkin_member(u)
                if mbr_data is not None:
                    if "PRIM-STAT" in mbr_data:
                        footer_text: str
                        if str(r.emoji) == "🔴":
                            if len(team1) == max_pcount:
                                footer_text = "Party Already Full"
                            else:
                                if u.id in [k.id for k in team1]:
                                    footer_text = f"🔴 {u.name}, You are already in this Team"
                                elif u.id in [k.id for k in team2]:
                                    indexRemove: int
                                    for omb in range(len(team2)):
                                        if team2[omb].id == u.id:
                                            indexRemove = omb
                                    obj = team2[indexRemove]
                                    team2.pop(indexRemove)
                                    team1.append(obj)
                                    footer_text = f"🔴 {u.name} Leave the Blue Team and Joined Red Team"
                                else:
                                    obj = checkClassID(u)
                                    team1.append(obj)
                                    footer_text = f"🔴 {u.name} Joined Red Team"
                        else:
                            if len(team2) == max_pcount:
                                footer_text = "Party Already Full"
                            else:
                                if u.id in [k.id for k in team1]:
                                    indexRemove: int
                                    for omb in range(len(team1)):
                                        if team1[omb].id == u.id:
                                            indexRemove = omb
                                    obj = team1[indexRemove]
                                    team1.pop(indexRemove)
                                    team2.append(obj)
                                    footer_text = f"🔵 {u.name} Leave the Red Team and Joined Blue Team"
                                elif u.id in [k.id for k in team2]:
                                    footer_text = f"🔵 {u.name}, You are already in this Team"
                                else:
                                    obj = checkClassID(u)
                                    team2.append(obj)
                                    footer_text = f"🔵 {u.name} Joined Blue Team"
                        await r.remove(u)
                        if len(team1) == max_pcount and len(
                                team2) == max_pcount:
                            break
                    else:
                        footer_text = f"{u.name} hasn't registered yet, type `{get_prefix(channel.guild)}start` to begin with RPG"

                    # Edit Hint Message
                    async with channel.typing():
                        emb = discord.Embed(
                            title="⌛ Waiting for Other Player to Join...",
                            description=f"{max_pcount}v{max_pcount} mode",
                            colour=WHITE)
                        emb.add_field(
                            name="🔴 Red Team",
                            inline=False,
                            value="\n".join([
                                f"> **{j.name}** ({j.ClassName})"
                                for j in team1
                            ]) if len(team1) > 0 else "```Empty Room```")
                        emb.add_field(
                            name="🔵 Blue Team",
                            inline=False,
                            value="\n".join([
                                f"> **{j.name}** ({j.ClassName})"
                                for j in team2
                            ]) if len(team2) > 0 else "```Empty Room```")
                        emb.set_footer(text=footer_text)
                    await hm.edit(embed=emb)

            # After it has been fulfiled, then let's Begin!
            await hm.delete()
            await self._lets_battle(channel, team1, team2)
        except asyncio.TimeoutError:
            await hm.delete(delay=1)
            await channel.send("*⚔️ Battle Canceled, Queue Timeout*")
            await self._cooling_down(channel.id)
Beispiel #18
0
 async def _learn(self, ctx: commands.Context, page: int = 1):
     mbr_data = checkin_member(ctx.author)
     if mbr_data is not None:
         if "moves" in mbr_data:
             if len(mbr_data["moves"]) < 3:
                 gld_data = checkin_guild(ctx.guild)
                 # No Moves Available
                 if len(gld_data["shop"]["movements"]) == 0:
                     emb = discord.Embed(
                         title=f"No Moves Available in {ctx.guild.name}",
                         description=
                         f"Create your first custom move, type `{get_prefix(ctx.guild)}create move` to make it up.",
                         colour=WHITE)
                     await ctx.send(embed=emb)
                 # There are moves in the guild
                 else:
                     move_data: list = gld_data["shop"]["movements"]
                     menu = ["⬅️", "✅", "🚫", "➡️"]
                     emb = embed_move_maker(move_data[page - 1])
                     emb.set_footer(
                         text=
                         "React with ✅ to learn this Move or 🚫 to abort.")
                     hm: discord.Message = await ctx.send(embed=emb)
                     for i in menu:
                         await hm.add_reaction(i)
                     try:
                         while True:
                             r, u = await self.bot.wait_for(
                                 event="reaction_add",
                                 timeout=30.0,
                                 check=lambda reaction, user: True
                                 if str(reaction.emoji) in menu and user ==
                                 ctx.author else False)
                             await hm.remove_reaction(str(r.emoji), u)
                             # Accept Training
                             if str(r.emoji) == "✅":
                                 for j in menu:
                                     await hm.remove_reaction(j, ctx.me)
                                 db_mbr.UpdateObject(
                                     {"member_id": str(ctx.author.id)}, {
                                         "$push": {
                                             "moves": move_data[page - 1]
                                         }
                                     })
                                 await hm.edit(
                                     content=
                                     f"{ctx.author.mention} learned `{move_data[page - 1]['NAME']}`."
                                 )
                                 break
                             # Abort Training
                             elif str(r.emoji) == "🚫":
                                 await hm.edit(content="*Action Aborted*")
                                 break
                             # Next Page
                             elif str(r.emoji) == "➡️":
                                 page = page + 1 if page < len(
                                     move_data) else 1
                             # Previous Page
                             elif str(r.emoji) == "⬅️":
                                 page = page - 1 if page > 0 else len(
                                     move_data)
                             # Edit Message Input
                             emb = embed_move_maker(move_data[page - 1])
                             emb.set_footer(
                                 text=
                                 "React with ✅ to learn this Move or 🚫 to abort."
                             )
                             await hm.edit(embed=emb)
                     except asyncio.TimeoutError:
                         await hm.edit(content="*Request Timeout*")
         else:
             await ctx.send(
                 f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__"
             )