Example #1
0
    async def dequeue(self):
        print('in dequeue')
        await self.class_message.delete()
        task = asyncio.get_event_loop().create_task(self.move_members())
        await self.raid_msg.clear_reactions()
        while not task.done():
            num = len(self.raid_vc.members)
            capacity_bar = utils.textProgressBar(num,
                                                 self.max_members,
                                                 prefix="",
                                                 percent_suffix=" Moved",
                                                 suffix="",
                                                 decimals=0,
                                                 length=13)
            embed = discord.Embed(title="Moving Members...",
                                  description=capacity_bar,
                                  color=discord.Color.orange())
            await self.raid_msg.edit(embed=embed)
            nvc = len(self.raid_vc.members)
            n_capacity_bar = utils.textProgressBar(nvc,
                                                   self.max_members,
                                                   prefix="",
                                                   percent_suffix=" Full",
                                                   suffix="",
                                                   decimals=0,
                                                   length=13)
            info_str = f"Moving Members...\n\n**{nvc}** Slots Filled in VC\n{n_capacity_bar}"
            self.cp_embed.set_field_at(4, name="Info:", value=info_str)
            await self.cp_msg.edit(embed=self.cp_embed)
            await asyncio.sleep(1.5)

        await self.end_afk()
Example #2
0
    async def update_start_embed(self, update_msg=False):
        nqueue = len(self.confirmed_raiders) + len(self.confirmed_priority)
        nvc = len(self.raid_vc.members) if self.raid_vc else 0
        capacity_bar = utils.textProgressBar(nqueue,
                                             self.max_members,
                                             prefix="",
                                             percent_suffix=" Full",
                                             suffix="",
                                             decimals=0,
                                             length=18)
        desc = f"**Join __{self.queuechannel.name}__ to to join the raiding queue!**\nUse `!position` to check your position in the queue.\n\n" \
               f"**{nqueue}** Members are in the queue & have been confirmed to join the raid!\n\n{capacity_bar}\n\nOnce you join the queue, react to {self.dungeon_emoji} to " \
               f"confirm you'd " \
               f"like to join this raid.\n\nIf you have a required item for this run, **first join __{self.queuechannel.name}__, then** react to the emojis below & confirm with " \
               f"the bot to skip the queue!\n\nIf you are one of my lovely patreons, react to: <:patreon:736944176469508118>  ⇒  `!patreon`"
        self.raid_start_embed.description = desc

        items = []
        items_str = ""
        for i in self.required_items:
            confirm = len(self.required_items[i]['confirmed'])
            max = self.required_items[i]['max']
            if confirm < max:
                items.append(f"{i} - **{confirm}**/{max}")
        items_str += " | ".join(items)
        items_str = items_str if items_str else "All required items have been confirmed already! Please wait for the run to start!"
        items_str += f"\n\n<:nitro:736138528710459473> Reserved Slots - **{len(self.nitroboosters)}/{self.max_nitro}**"
        items_str += f"\n\n<:patreon:736944176469508118> Reserved Slots - **{len(self.patreons)}/{self.max_patreons}**"
        self.raid_start_embed.set_field_at(0,
                                           name="Items Needed:",
                                           value=items_str,
                                           inline=False)

        self.raid_start_embed.set_footer(
            text=f"{nvc}/{self.max_members} Slots Filled | Queue Started at ")

        if update_msg:
            await self.raid_msg.edit(embed=self.raid_start_embed)
Example #3
0
    async def realmeye(self, ctx, member: utils.MemberLookupConverter = None):
        if not member:
            member = ctx.author
        udata = await sql.get_user(self.client.pool, member.id)
        if not udata:
            return await ctx.send(
                "The specified user was not found in the database!")
        ign = udata[sql.usr_cols.ign]

        embed = discord.Embed(
            title="Fetching...",
            description=
            "Please wait while your player-data is being retrieved.\nThis can take up to a minute if realmeye's servers are "
            "being slow! (They usually are)",
            color=discord.Color.orange())
        embed.set_thumbnail(url="https://i.imgur.com/nLRgnZf.gif")
        msg = await ctx.send(embed=embed)

        try:
            async with aiohttp.ClientSession(
                    timeout=aiohttp.ClientTimeout(10)) as cs:
                async with cs.get(
                        f'https://nightfirec.at/realmeye-api/?player={ign}'
                ) as r:
                    if r.status == 403:
                        print("ERROR: API ACCESS FORBIDDEN")
                        await ctx.send(
                            f"<@{self.client.owner_id}> ERROR: API ACCESS REVOKED!."
                        )
                    data = await r.json()  # returns dict
                if not data:
                    try:
                        await msg.delete()
                    except discord.NotFound:
                        pass
                    return await ctx.send(
                        "There was an issue retrieving realmeye data. Please try the command later."
                    )
            if 'error' in data:
                try:
                    await msg.delete()
                except discord.NotFound:
                    pass
                embed = discord.Embed(
                    title='Error!',
                    description=
                    f"There were no players found on realmeye with the name `{ign}`.",
                    color=discord.Color.red())
                return await ctx.send(embed=embed)
        except asyncio.TimeoutError:
            try:
                await msg.delete()
            except discord.NotFound:
                pass
            return await ctx.send(
                "There was an issue retrieving realmeye data. Please try the command later."
            )

        d = f"{member.mention}\n"
        d += f"**{data['desc1']}**\n" if data['desc1'] else ""
        d += f"{data['desc2']}\n" if data['desc2'] else ""
        d += f"{data['desc3']}\n" if data['desc3'] else ""
        d += f"\n\nGuild: [{data['guild']}](https://www.realmeye.com/guild/{data['guild'].replace(' ', '%20')}) ({data['guild_rank']})" if data[
            'guild'] else ""
        base_embed = discord.Embed(
            title=f"Realmeye Info for {ign}",
            description=d,
            url=f'https://www.realmeye.com/player/{ign}',
            color=discord.Color.blue())
        info = f"Characters: **{data['chars']}**\nSkins: **{data['skins']}**\nFame: **{data['fame']:,}**<:fame:682209281722024044>\nEXP: **{data['exp']:,}**\nStars: **" \
               f"{data['rank']}**⭐\n\nAccount Fame: **{data['account_fame']:,}**<:fame:682209281722024044>\n"
        info += f"Created: {data['created']}" if 'created' in data else f"First Seen: {data['player_first_seen']}" if 'player_first_seen' in data else ""
        info += f"\nLast Seen: {data['player_last_seen']}\nCharacters Hidden: {'✅' if data['characters_hidden'] else '❌'}"

        if not data['characters_hidden'] and data['characters']:
            base_embed.add_field(
                name="Info",
                value=info +
                "\n\nCharacter Data continues on the next page...",
                inline=False)
            base_embed.set_footer(
                text='© Darkmattr | Use the reactions to flip pages',
                icon_url=member.avatar_url)
            with open('data/itemImages.json') as file:
                item_images = json.load(file)
            with open('data/skinImages.json') as file:
                skin_images = json.load(file)
            with open('data/createdItemImages.json') as file:
                created_images: dict = json.load(file)

            embeds = []
            embeds.append(base_embed)
            for c in data['characters']:
                embed = discord.Embed(
                    title=f"Characters of {ign}: {c['class']}",
                    color=discord.Color.teal())
                ids = [
                    c['equips']['data_weapon_id'],
                    c['equips']['data_ability_id'],
                    c['equips']['data_armor_id'], c['equips']['data_ring_id']
                ]
                i_str = "-".join([str(id) for id in ids])
                if i_str in created_images:
                    i_url = created_images[i_str]
                else:
                    i_url = await make_equips_img(ids, item_images)
                    created_images[i_str] = i_url
                    with open('data/createdItemImages.json', 'w') as file:
                        json.dump(created_images, file)
                embed.set_image(url=i_url)
                embed.set_thumbnail(url=skin_images[str(c['data_class_id'])][
                    str(c['data_skin_id'])])
                desc = f"Class Quests: **{c['cqc']}/5** Quests\nEXP: **{c['exp']:,}**xp\nLevel: **{c['level']}**\nStats Maxed: " \
                       f"**{c['stats_maxed']}/8**\nPlace: **{c['place']:,}**\nBackpack: "
                desc += "✅" if c['backpack'] else "❌"
                desc += "\nPet: "
                desc += f"✅\nPet Name: {c['pet']}" if c['pet'] else "❌"
                embed.description = desc
                stat_d = c['stats']
                hp_bar = utils.textProgressBar(stat_d['hp'],
                                               max_stats[c['class']][0],
                                               decimals=0,
                                               prefix='',
                                               percent_suffix="  Maxed",
                                               suffix="",
                                               length=12,
                                               fullisred=False)
                mp_bar = utils.textProgressBar(stat_d['mp'],
                                               max_stats[c['class']][1],
                                               decimals=0,
                                               prefix='',
                                               percent_suffix=" Maxed",
                                               suffix="",
                                               length=12,
                                               fullisred=False)
                att_bar = utils.textProgressBar(stat_d['attack'],
                                                max_stats[c['class']][2],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)
                def_bar = utils.textProgressBar(stat_d['defense'],
                                                max_stats[c['class']][3],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)
                spd_bar = utils.textProgressBar(stat_d['speed'],
                                                max_stats[c['class']][4],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)
                dex_bar = utils.textProgressBar(stat_d['dexterity'],
                                                max_stats[c['class']][5],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)
                vit_bar = utils.textProgressBar(stat_d['vitality'],
                                                max_stats[c['class']][6],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)
                wis_bar = utils.textProgressBar(stat_d['wisdom'],
                                                max_stats[c['class']][7],
                                                decimals=0,
                                                prefix='',
                                                percent_suffix=" Maxed",
                                                suffix="",
                                                length=6,
                                                fullisred=False)

                hp_s = f"HP: **{stat_d['hp']}/{max_stats[c['class']][0]}**\n{hp_bar}\n" \
                         f"MP: **{stat_d['mp']}/{max_stats[c['class']][1]}**\n{mp_bar}\n"
                stat_s_1 = f"ATT: **{stat_d['attack']}/{max_stats[c['class']][2]}** | {att_bar}\n" \
                         f"DEF: **{stat_d['defense']}/{max_stats[c['class']][3]}** | {def_bar}\n" \
                         f"SPD: **{stat_d['speed']}/{max_stats[c['class']][4]}** | {spd_bar}\n"
                stat_s_2 = f"DEX: **{stat_d['dexterity']}/{max_stats[c['class']][5]}** | {dex_bar}\n" \
                         f"VIT: **{stat_d['vitality']}/{max_stats[c['class']][6]}** | {vit_bar}\n" \
                         f"WIS: **{stat_d['wisdom']}/{max_stats[c['class']][7]}** | {wis_bar}"
                embed.add_field(name="Health & Mana", value=hp_s, inline=False)
                embed.add_field(name="Stats:", value=stat_s_1, inline=False)
                embed.add_field(name="More Stats:", value=stat_s_2)
                embed.set_footer(
                    text='© Darkmattr | Use the reactions to flip pages')
                embeds.append(embed)

            paginator = utils.EmbedPaginator(self.client, ctx, embeds)
            try:
                await msg.delete()
            except discord.NotFound:
                pass
            return await paginator.paginate()

        base_embed.add_field(name="Info", value=info, inline=False)
        await msg.edit(embed=base_embed)
Example #4
0
    async def update_cp_embed(self, update_msg=False):
        item_str = ""
        for i in self.required_items:
            item_str += f"{i} - {' | '.join(m.mention for m in self.required_items[i]['confirmed'])} |⇒ ({len(self.required_items[i]['confirmed'])}/" \
                        f"{self.required_items[i]['max']})\n"
        self.cp_embed.set_field_at(2,
                                   name="Required Reactions:",
                                   value=item_str,
                                   inline=False)

        nitro_str = f"<:nitro:736138528710459473> - " \
                    f"{' | '.join([m.mention for m in self.nitroboosters])} |⇒ ({len(self.nitroboosters)}/{self.max_nitro})"
        nitro_str += f"\n<:patreon:736944176469508118> - " \
                     f"{' | '.join([m.mention for m in self.patreons])} |⇒ ({len(self.patreons)}/{self.max_patreons})"
        self.cp_embed.set_field_at(3,
                                   name="Nitro Boosters / Patreons:",
                                   value=nitro_str,
                                   inline=False)

        nqueue = len(self.confirmed_raiders) + len(self.confirmed_priority)
        nvc = len(self.raid_vc.members)
        q_capacity_bar = utils.textProgressBar(nqueue,
                                               self.max_members,
                                               prefix="",
                                               percent_suffix=" Full",
                                               suffix="",
                                               decimals=0,
                                               length=15)
        n_capacity_bar = utils.textProgressBar(nvc,
                                               self.max_members,
                                               prefix="",
                                               percent_suffix=" Full",
                                               suffix="",
                                               decimals=0,
                                               length=15)
        info_str = f"**{nqueue}** Members are currently in the queue to join the raid!\n{q_capacity_bar}\n\n**{nvc}** Slots Filled in VC\n{n_capacity_bar}\n\n" \
                   "Start the AFK once you have confirmed enough reactions.\nReact to the 📥 emoji to start, 🛑 to abort."
        self.cp_embed.set_field_at(4,
                                   name="Info:",
                                   value=info_str,
                                   inline=False)

        self.class_message = await self.hcchannel.fetch_message(
            self.class_message.id)
        classes = ""
        for c in self.class_emojis[:3]:
            num = next(
                (r.count
                 for r in self.class_message.reactions if str(r.emoji) == c),
                1) - 1
            bar = utils.textProgressBar(num,
                                        self.max_members,
                                        prefix="",
                                        percent_suffix=" ",
                                        suffix="",
                                        decimals=0,
                                        length=10,
                                        fullisred=False)
            classes += f"{c} - {bar}\n"
        self.cp_embed.set_field_at(5,
                                   name="Class Reactions (1):",
                                   value=classes,
                                   inline=False)
        classes = ""
        for c in self.class_emojis[3:]:
            num = next(
                (r.count
                 for r in self.class_message.reactions if str(r.emoji) == c),
                1) - 1
            bar = utils.textProgressBar(num,
                                        self.max_members,
                                        prefix="",
                                        percent_suffix=" ",
                                        suffix="",
                                        decimals=0,
                                        length=10,
                                        fullisred=False)
            classes += f"{c} - {bar}\n"
        self.cp_embed.set_field_at(6,
                                   name="Class Reactions (2):",
                                   value=classes,
                                   inline=False)

        if update_msg:
            await self.cp_msg.edit(embed=self.cp_embed)
Example #5
0
    async def end_afk(self):
        print("in end afk")

        embed = discord.Embed(
            description=
            f"This raid is running with **{len(self.raiderids)}** members.\nIf you get disconnected, rejoin {self.queuechannel.name} to be moved "
            f"in.\n\n__If you "
            f"weren't moved in for this afk, **stay in {self.queuechannel.name}** to keep your position for the "
            f"next raid.__\n\nStaying in the {self.queuechannel.name} VC will ensure you make it to a subsequent run!",
            color=self.dungeon_color)
        embed.set_thumbnail(url=self.dungeon_boss_image)
        embed.set_author(
            name=f"{self.dungeontitle} Raid is currently runnning!",
            icon_url=self.dungeon_image)

        classes = ""
        for c in self.class_emojis[:3]:
            num = next(
                (r.count
                 for r in self.class_message.reactions if str(r.emoji) == c),
                0)
            bar = utils.textProgressBar(num,
                                        self.max_members,
                                        prefix="",
                                        percent_suffix=" Full",
                                        suffix="",
                                        decimals=0,
                                        length=10,
                                        fullisred=False)
            classes += f"{c} - {bar}\n"
        embed.add_field(name="Class Reactions (1):",
                        value=classes,
                        inline=False)
        classes = ""
        for c in self.class_emojis[3:]:
            num = next(
                (r.count
                 for r in self.class_message.reactions if str(r.emoji) == c),
                0)
            bar = utils.textProgressBar(num,
                                        self.max_members,
                                        prefix="",
                                        percent_suffix=" Full",
                                        suffix="",
                                        decimals=0,
                                        length=10,
                                        fullisred=True)
            classes += f"{c} - {bar}\n"
        embed.add_field(name="Class Reactions (2):",
                        value=classes,
                        inline=False)
        embed.set_footer(text="Raid Started ")
        embed.timestamp = datetime.utcnow()

        await self.raid_msg.edit(content="", embed=embed)

        del self.client.raid_db[self.ctx.guild.id]['afk'][self.raid_msg.id]

        # Update cp with class info
        self.cp_embed.description += "\n\nPlease go to location ASAP & wait for bot to tell you when to call!"
        self.cp_embed.set_field_at(1,
                                   name="Run Location:",
                                   value=self.location)
        await self.cp_msg.edit(embed=self.cp_embed)

        print("before update cp")

        print('dming members')
        # DM MEMBERS
        for i in self.required_items:
            for m in self.required_items[i]['confirmed']:
                await m.send(
                    f"The location is: {self.location}.\nYou have 15 seconds before location is called for everyone."
                )

        for m in self.patreons:
            await m.send(
                f"The location is: {self.location}.\nYou have 15 seconds before location is called for everyone."
            )

        for m in self.nitroboosters:
            await m.send(
                f"The location is: {self.location}.\nYou have 15 seconds before location is called for everyone."
            )

        print('print done sending dms')

        self.cp_embed.description += "\nLocation has been sent to all members with required items."
        await self.cp_msg.edit(embed=self.cp_embed)
        await asyncio.sleep(15)

        await self.ctx.author.send(
            f"CALL NOW: `{self.location}`\n{self.ctx.author.mention}")
        self.cp_embed.description = f"QAFK [**Control Panel**]({self.raid_msg.jump_url}) for **{self.dungeontitle}** | Started by {self.ctx.author.mention}\n\n" \
                                    "__**CALL LOCATION NOW!**__"
        await self.cp_msg.edit(embed=self.cp_embed)
        await asyncio.sleep(5)

        self.cp_embed.description = f"QAFK [**Control Panel**]({self.raid_msg.jump_url}) for **{self.dungeontitle}** | Started by {self.ctx.author.mention}\n\n" \
                                    "Press the 🔓 emoji to unlock the raid vc.\nPress the 📤 button when you are done with the run."
        await self.cp_msg.edit(embed=self.cp_embed)
        await self.cp_msg.add_reaction('🔓')
        await self.cp_msg.add_reaction('<:gray:736515579103543336>')
        await self.cp_msg.add_reaction('📤')

        self.in_run = True