Example #1
0
    async def qafk(self, ctx, *, location):
        if ctx.author.id in self.client.raid_db[ctx.guild.id]['leaders']:
            return await ctx.send(
                "You cannot start another AFK while an AFK check is still up or a run log has not been completed."
            )

        if not ('us' in location.lower() or 'eu' in location.lower()):
            return await ctx.send("Please Choose a US or EU Location!")

        is_us = True if 'us' in location.lower() else False

        self.client.raid_db[ctx.guild.id]['leaders'].append(ctx.author.id)

        setup = VCSelect(self.client, ctx, qafk=True)
        data = await setup.q_start()
        if isinstance(data, tuple):
            (raiderrole, rlrole, hcchannel) = data
        else:
            self.client.raid_db[ctx.guild.id]['leaders'].remove(ctx.author.id)
            return

        qafk = QAfk(self.client, ctx, location, hcchannel, raiderrole, rlrole,
                    is_us)
        await qafk.start()
        self.client.raid_db[ctx.guild.id]['leaders'].remove(ctx.author.id)
Example #2
0
 async def parse(self, ctx):
     if not ctx.message.attachments:
         return await ctx.send(
             "Please attach an image containing only the result of the /who command!",
             delete_after=10)
     if len(ctx.message.attachments) > 1:
         return await ctx.send("Please only attach 1 image.",
                               delete_after=10)
     attachment = ctx.message.attachments[0]
     if not ".jpg" in attachment.filename and not ".png" in attachment.filename:
         return await ctx.send(
             "Please only attach an image of type 'png' or 'jpg'.",
             delete_after=10)
     image = io.BytesIO()
     await attachment.save(image, seek_begin=True)
     if ctx.author.voice:
         vcchannel = ctx.author.voice.channel
     else:
         setup = VCSelect(self.client, ctx, parse=True)
         data = await setup.start()
         if isinstance(data, tuple):
             (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
              hcchannel, vcchannel, setup_msg) = data
         else:
             return
         await setup_msg.delete()
     msg = await ctx.send("Parsing image. This may take a minute...")
     embed = await self.client.loop.run_in_executor(
         None, functools.partial(parse_image, ctx.author, image, vcchannel))
     await msg.delete()
     await ctx.send(embed=embed)
Example #3
0
    async def clean(self, ctx, channel: discord.VoiceChannel = None):
        vcchannel = channel
        if not channel:
            setup = VCSelect(self.client, ctx, clean=True)
            data = await setup.start()
            if isinstance(data, tuple):
                (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
                 hcchannel, vcchannel, setup_msg) = data
            else:
                return
            await setup_msg.delete()

            await vcchannel.set_permissions(raiderrole,
                                            connect=False,
                                            view_channel=True,
                                            speak=False)

            for member in vcchannel.members:
                if member.top_role < rlrole:
                    if member.voice:
                        await member.move_to(channel=None)

        for member in vcchannel.members:
            if member.voice:
                await member.move_to(channel=None)

        embed = discord.Embed(
            title="Done Cleaning!",
            description=f"{vcchannel.name} has been cleaned and locked.",
            color=discord.Color.green())
        await ctx.send(embed=embed)
Example #4
0
 async def runecount(self, ctx):
     setup = VCSelect(self.client, ctx, qafk=True)
     data = await setup.q_start()
     if isinstance(data, tuple):
         (raiderrole, rlrole, hcchannel) = data
     else:
         return
     runecount = RuneCount(self.client, ctx, hcchannel, raiderrole, rlrole)
Example #5
0
 async def headcount(self, ctx):
     setup = VCSelect(self.client, ctx, headcount=True)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         return
     hc = Headcount(self.client, ctx, hcchannel, vcchannel, setup_msg,
                    raidnum, inraiding, invet, inevents, raiderrole, rlrole)
     await hc.start()
Example #6
0
 async def realmclear(self, ctx, *, location):
     if ctx.author.id in self.client.raid_db[ctx.guild.id]['leaders']:
         return await ctx.send(
             "You cannot start another AFK while an AFK check is still up.")
     # self.client.raid_db[ctx.guild.id]['leaders'].append(ctx.author.id)
     setup = VCSelect(self.client, ctx)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         return
     rc = RealmClear(self.client, ctx, location, raidnum, inraiding, invet,
                     inevents, raiderrole, rlrole, hcchannel, vcchannel,
                     setup_msg)
     await rc.start()
Example #7
0
    async def qafk(self, ctx):
        if ctx.author.id in self.client.raid_db[ctx.guild.id]['leaders']:
            return await ctx.send(
                "You cannot start another AFK while an AFK check is still up or a run log has not been completed."
            )

        setup = VCSelect(self.client, ctx, qafk=True)
        data = await setup.q_start()
        if isinstance(data, tuple):
            (raiderrole, rlrole, hcchannel) = data
        else:
            return

        qafk = QAfk(self.client, ctx, "Location has not been set yet.",
                    hcchannel, raiderrole, rlrole, True)
        await qafk.start()
Example #8
0
 async def unlock(self, ctx):
     setup = VCSelect(self.client, ctx, unlock=True)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         return
     await setup_msg.delete()
     await vcchannel.set_permissions(raiderrole,
                                     connect=True,
                                     view_channel=True,
                                     speak=False)
     embed = discord.Embed(
         description=f"{vcchannel.name} Has been Unlocked!",
         color=discord.Color.green())
     await ctx.send(embed=embed)
Example #9
0
 async def afk(self, ctx, *, location):
     if ctx.author.id in self.client.raid_db[ctx.guild.id]['leaders']:
         return await ctx.send(
             "You cannot start another AFK while an AFK check is still up or a run log has not been completed."
         )
     self.client.raid_db[ctx.guild.id]['leaders'].append(ctx.author.id)
     setup = VCSelect(self.client, ctx)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         self.client.raid_db[ctx.guild.id]['leaders'].remove(ctx.author.id)
         return
     afk = AfkCheck(self.client, ctx, location, raidnum, inraiding, invet,
                    inevents, raiderrole, rlrole, hcchannel, vcchannel,
                    setup_msg)
     await afk.start()
Example #10
0
 async def lock(self, ctx):
     setup = VCSelect(self.client, ctx, lock=True)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         return
     await setup_msg.delete()
     # vc_name = vcchannel.name
     # if " <-- Join!" in vc_name:
     #     vc_name = vc_name.split(" <")[0]
     #     await vcchannel.edit(name=vc_name)
     await vcchannel.set_permissions(raiderrole,
                                     connect=False,
                                     view_channel=True,
                                     speak=False)
     embed = discord.Embed(description=f"{vcchannel.name} Has been Locked!",
                           color=discord.Color.red())
     await ctx.send(embed=embed)
Example #11
0
 async def changecap(self, ctx, new_cap: int):
     if new_cap < -1 or new_cap == 0 or new_cap > 99:
         return await ctx.send(
             "Please set the channel cap to a number between 1-99 or -1 for unlimited"
         )
     if new_cap == -1:
         new_cap = None
     setup = VCSelect(self.client, ctx, change_limit=True)
     data = await setup.start()
     if isinstance(data, tuple):
         (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
          hcchannel, vcchannel, setup_msg) = data
     else:
         return
     await setup_msg.delete()
     await vcchannel.edit(user_limit=new_cap)
     embed = discord.Embed(
         description=
         f"{vcchannel.name} now has a user limit of **{f'{new_cap}' if new_cap else 'Unlimited'}!**",
         color=discord.Color.green())
     await ctx.send(embed=embed)
Example #12
0
    async def parsemembers(self, ctx):
        if not ctx.message.attachments:
            return await ctx.send(
                "Please attach an image containing only the result of the /who command!",
                delete_after=10)
        if len(ctx.message.attachments) > 1:
            return await ctx.send("Please only attach 1 image.",
                                  delete_after=10)
        attachment = ctx.message.attachments[0]
        if not attachment.height or 'mp4' in attachment.filename.lower(
        ) or 'mov' in attachment.filename.lower():
            return await ctx.send(
                "Please only attach an image of type 'png' or 'jpg'.",
                delete_after=10)
        image = io.BytesIO()
        await attachment.save(image, seek_begin=True)
        if ctx.author.voice:
            vcchannel = ctx.author.voice.channel
        else:
            setup = VCSelect(self.client, ctx, parse=True)
            data = await setup.start()
            if isinstance(data, tuple):
                (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
                 hcchannel, vcchannel, setup_msg) = data
            else:
                return
            await setup_msg.delete()
        msg: discord.Message = await ctx.send(
            "Parsing image. This may take a minute...")
        res = await self.client.loop.run_in_executor(
            None,
            functools.partial(parse_image, ctx.author, image, vcchannel, True))
        if not res:
            embed = discord.Embed(
                title="Error!",
                description=
                "Could not find the who command in the image you provided.\nPlease re-run the "
                "command with an image that shows the results of `/who`.",
                color=discord.Color.red())
            await msg.delete()
            return await ctx.send(embed=embed)

        crashing, possible_alts, fixed_names = res
        await msg.edit(content="Parsing members. Please wait...")
        n_crashers = len(crashing)
        crashing_members = []
        converter = utils.MemberLookupConverter()
        pages = []
        nm_crashing = []
        crashing_players = []
        for n in crashing:
            try:
                mem = await converter.convert(ctx, n)
            except discord.ext.commands.BadArgument:
                crashing_players.append(n)
        for m in crashing_members:
            n_suspensions = 0
            active_suspension = "❌"
            pdata = await sql.get_users_punishments(self.client.pool, m.id,
                                                    ctx.guild.id)
            bdata = await sql.get_blacklist(self.client.pool, m.id,
                                            ctx.guild.id)
            pembed = discord.Embed(
                description=
                f"**Punishment Log for {m.mention}** - `{m.display_name}`")
            if pdata:
                for i, r in enumerate(pdata, start=1):
                    requester = ctx.guild.get_member(r[sql.punish_cols.r_uid])
                    active = "✅" if r[sql.punish_cols.active] else "❌"
                    starttime = f"Issued at: `{r[sql.punish_cols.starttime].strftime('%b %d %Y %H:%M:%S')}`"
                    endtime = f"\nEnded at: `{r[sql.punish_cols.endtime].strftime('%b %d %Y %H:%M:%S')}`" if r[
                        sql.punish_cols.endtime] else ""
                    ptype = r[sql.punish_cols.type].capitalize()
                    pembed.add_field(
                        name=f"{ptype} #{i} | Active {active}",
                        value=
                        f"Issued by: {requester.mention if requester else '(Issuer left server)'}\nReason:\n{r[sql.punish_cols.reason]}\n{starttime}\n"
                        f"{endtime}",
                        inline=False)
                    if r[sql.punish_cols.active] and ptype == 'Suspend':
                        active_suspension = active
                    if ptype == 'Suspend':
                        n_suspensions += 1
            if bdata:
                for i, r in enumerate(bdata, start=1):
                    requester = ctx.guild.get_member(r[sql.blacklist_cols.rid])
                    active = "✅"
                    starttime = f"Issued at: `{r[sql.blacklist_cols.issuetime].strftime('%b %d %Y %H:%M:%S')}`"
                    btype = r[sql.blacklist_cols.type].capitalize()
                    pembed.add_field(
                        name=
                        f"{btype} #{i} issued by {requester.mention if requester else '(Issuer left server)'} | Active {active}",
                        value=
                        f"Reason:\n{r[sql.punish_cols.reason]}\n{starttime}")
            if pdata or bdata:
                pembed.description += f"\nFound `{len(pdata)}` Punishments in this user's history.\nFound `{len(bdata)}` Blacklists in this users history."
                pages.append(pembed)

            nm_crashing.append((m, n_suspensions, active_suspension))

        mstring = ""
        nm_crashing = sorted(nm_crashing, key=lambda x: x[1], reverse=True)
        for r in nm_crashing:
            mstring += f"{r[0].mention} **-** `{r[0].display_name}`\nSuspensions: **{r[1]}** | Active: {r[2]}\n"
        if not mstring:
            mstring = "No members crashing!"

        embed = discord.Embed(
            title=f"Parsing Results for {vcchannel.name}",
            description=f"Possible Crashers: **{n_crashers}**",
            color=discord.Color.orange())
        if len(mstring) > 1024:
            lines = mstring.splitlines(keepends=True)
            curr_str = ""
            n_sections = 1
            for l in lines:
                if len(l) + len(curr_str) >= 1024:
                    embed.add_field(
                        name=
                        f"Members Crashing (in the server) ({n_sections}):",
                        value=curr_str,
                        inline=True)
                    curr_str = l
                    n_sections += 1
                else:
                    curr_str += l
            embed.add_field(
                name=f"Members Crashing (in the server) ({n_sections}):",
                value=curr_str,
                inline=True)
        else:
            embed.add_field(name="Members Crashing (in the server):",
                            value=mstring,
                            inline=True)
        pstring = "\n".join(
            crashing_players
        ) if crashing_players else 'No players who are not in the server crashing.'
        embed.add_field(name="Players Crashing (not in server):",
                        value=pstring,
                        inline=False)

        if fixed_names:
            fixedlist = "     Fixed Name | Original Parse".join(
                "`/kick " + fixed + "` | (" + orig + ")\n"
                for (orig, fixed) in fixed_names)
            embed.add_field(name="Possible Fixed Names",
                            value=fixedlist,
                            inline=True)
        if possible_alts:
            altlist = "".join("`" + name + "`\n" for name in possible_alts)
            embed.add_field(name="Possible Alts (In VC but not in game)",
                            value=altlist,
                            inline=True)

        pages.insert(0, embed)

        await msg.delete()
        paginator = utils.EmbedPaginator(self.client, ctx, pages)
        await paginator.paginate()
Example #13
0
    async def logrun(self,
                     ctx,
                     member: utils.MemberLookupConverter = None,
                     number=1):
        if not member:
            member = ctx.author

        setup = VCSelect(self.client, ctx, manual_log=True)
        data = await setup.start()
        if isinstance(data, tuple):
            (raidnum, inraiding, invet, inevents, raiderrole, rlrole,
             hcchannel, vcchannel, setup_msg) = data
        else:
            return

        try:
            await setup_msg.delete()
        except discord.NotFound:
            pass
        r_msg = await ctx.send(embed=embeds.dungeon_select(manual_log=True))

        def dungeon_check(m):
            return m.author == ctx.author and m.channel == ctx.channel and m.content.isdigit(
            )

        while True:
            try:
                msg = await self.client.wait_for('message',
                                                 timeout=60,
                                                 check=dungeon_check)
            except asyncio.TimeoutError:
                embed = discord.Embed(
                    title="Timed out!",
                    description="You didn't choose a dungeon in time!",
                    color=discord.Color.red())
                await r_msg.clear_reactions()
                return await r_msg.edit(embed=embed)

            if msg.content.isdigit():
                if 0 < int(msg.content) < 57:
                    break
            await ctx.send("Please choose a number between 1-56!",
                           delete_after=7)

        await r_msg.delete()
        dungeon_info = utils.dungeon_info(int(msg.content))
        try:
            await msg.delete()
        except discord.NotFound:
            pass
        dungeontitle = dungeon_info[0]
        emojis = dungeon_info[1]
        guild_db = self.client.guild_db.get(ctx.guild.id)
        logrun = LogRun(self.client,
                        ctx.author,
                        ctx.channel,
                        ctx.guild,
                        emojis, [],
                        dungeontitle, [member.id],
                        guild_db.get(sql.gld_cols.rlroleid),
                        hcchannel,
                        events=inevents,
                        vialreacts=[],
                        helmreacts=[],
                        shieldreacts=[],
                        swordreacts=[],
                        numruns=number,
                        runleader=member)
        await logrun.start()