Ejemplo n.º 1
0
    async def help(self, ctx, cog: str = None):
        """Show this message"""
        if not cog:
            help_embed = discord.Embed(
                title='ZedUtil Cog Listings',
                description='Use `>help [cog]` to find out more about them!',
                color=Color.darker_gray())

            help_embed.set_author(
                name=f'{ctx.message.content}',
                icon_url=ctx.author.avatar_url,
                url="https://github.com/foxnerdsaysmoo/zedutils#features")

            cogs_desc = ''
            for x in self.bot.cogs:
                if not hasattr(self.bot.cogs[x], 'hidden'):
                    cogs_desc += '[{}]({})'.format(
                        x, "https://github.com/foxnerdsaysmoo/zedutils#" +
                        self.bot.cogs[x].__doc__) + '\n'
            help_embed.add_field(name='Cogs',
                                 value=cogs_desc[0:len(cogs_desc) - 1],
                                 inline=False)

            await ctx.send(embed=help_embed)
        else:
            found = False
            for x, i in self.bot.cogs.items():
                if x.lower() == cog.lower():
                    if not hasattr(self.bot.cogs[x], 'hidden'):
                        url = "https://github.com/foxnerdsaysmoo/zedutils#" + self.bot.cogs[
                            x].__doc__
                        help_embed = discord.Embed(title=f'{x} help',
                                                   url=url,
                                                   color=Color.darker_gray())
                        help_embed.set_author(name=f'{ctx.message.content}',
                                              icon_url=ctx.author.avatar_url,
                                              url=url)
                    else:
                        help_embed = discord.Embed(
                            title=f'{x}',
                            description=self.bot.cogs[x].__doc__,
                            color=Color.darker_gray())
                    commands_ = ''
                    for c in i.get_commands():
                        if not c.hidden:
                            commands_ += f'**{c.name}** - {c.help}\n'

                    help_embed.add_field(name='Commands', value=commands_)

                    found = True

            if not found:
                raise errors.UserInputError('Invalid cog name')

            await ctx.send(embed=help_embed)
Ejemplo n.º 2
0
    async def search(self, ctx, query, pageno=1):
        if ctx.author.id in data['bannedids']:
            await ctx.send(
                ':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**'
            )
            return

        doujinlist = []
        doujinlist.extend(nh.search(query=query, page=1, sort_by='popular'))
        doujinlist.extend(nh.search(query=query, page=2, sort_by='popular'))

        partitions = int(len(doujinlist) / 5)

        titlegroups = []

        for i in range(partitions):
            i += 1

            start = (i * 5) - 5
            end = i * 5

            titlegroup = []

            for index in range(len(doujinlist)):
                if index >= start and index < end:
                    doujin = doujinlist[index]
                    title = doujin.titles["pretty"]

                    titlemsg = f'`{title}: `**`{doujin.id}`**\n'

                    titlegroup.append(titlemsg)

            titlegroups.append(titlegroup)

            i -= 1

        if len(titlegroups) == 0:
            await ctx.send('`No results where found, senpai!`')

        else:
            embed = Embed(title=f'Search Results for: \"{query}\"',
                          color=Color.darker_gray())

            embed.set_footer(
                text=
                f'Requested by {ctx.author.name}#{ctx.author.discriminator}, Page: {pageno}',
                icon_url=ctx.author.avatar_url)

            titlegroup = titlegroups[pageno]

            titlemsg = ''

            for title in titlegroup:
                titlemsg += title

            embed.description = f'{titlemsg}'

            await ctx.send(embed=embed)
Ejemplo n.º 3
0
    async def tags(self, ctx, code: int):
        if ctx.author.id in data['bannedids']:
            await ctx.send(
                ':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**'
            )
            return

        if isinstance(code, int):
            nsfwlogo = File("assets/images/nsfwlogo.png",
                            filename="nsfwlogo.png")

            try:
                doujin = nh.get_doujin(code)
                title = doujin.titles['pretty']

                tagmsg = ''

                for tag in doujin.tags:
                    if tag.count > 999: tagnum = str(tag.count)[:-3] + 'k'
                    else: tagnum = str(tag.count)

                    tagmsg += f'**`{tag.name}: `**`{tagnum},`   '

                embed = Embed(title=f'Tags of {code}',
                              color=Color.darker_gray())

                embed.url = doujin.url

                embed.add_field(name='Tags of doujin:',
                                value=tagmsg,
                                inline=False)

                if ctx.channel.is_nsfw(
                ) or ctx.channel.id in data['pseudo_nsfw']:
                    embed.set_thumbnail(url=doujin.thumbnail)
                else:
                    embed.set_thumbnail(url='attachment://nsfwlogo.png')

                embed.set_footer(
                    text=
                    f'Requested by {ctx.author.name}#{ctx.author.discriminator}',
                    icon_url=ctx.author.avatar_url)

                if ctx.channel.is_nsfw(
                ) or ctx.channel.id in data['pseudo_nsfw']:
                    await ctx.send(embed=embed)
                else:
                    await ctx.send(file=nsfwlogo, embed=embed)

            except Exception as e:
                print(e)
                if str(e) == 'A doujin with the given id wasn\'t found':
                    await ctx.send(
                        '`Sorry senpai, but the doujin was not found!`')

        else:
            await ctx.send('`I don\'t think thats a code, senpai....`')
Ejemplo n.º 4
0
    async def invite(self, ctx):
        invite_link = data["invite"]

        embed = Embed(
            title='Invite Exinor',
            description=f'**[Click Here!]({invite_link} "Invite Exinor")**',
            color=Color.darker_gray())

        embed.set_thumbnail(url=self.client.user.avatar_url)

        await ctx.send(embed=embed)
Ejemplo n.º 5
0
    async def vote(self, ctx):
        embed = Embed(
            title=f'Vote for Nen!',
            description=
            f'**Senpai can vote for Nen at top.gg!**\n**[Vote Here!]({data["vote"]})**\nBy voting you can help Nen grow and find its home\nin many servers!',
            color=Color.darker_gray())

        embed.url = data['vote']
        embed.set_thumbnail(url=self.client.user.avatar_url)
        embed.set_footer(
            text=f'Requested by {ctx.author.name}#{ctx.author.discriminator}',
            icon_url=ctx.author.avatar_url)

        await ctx.send(embed=embed)
Ejemplo n.º 6
0
    async def read(self, ctx, code: int):
        if ctx.author.id in data['bannedids']:
            await ctx.send(
                ':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**'
            )
            return

        if ctx.channel.is_nsfw() or ctx.channel.id in data['pseudo_nsfw']:
            if isinstance(code, int):
                try:
                    doujin = nh.get_doujin(code)

                    # Wrapping the title
                    title = doujin.titles['pretty']
                    titlelist = wrapper.wrap(text=title)
                    wrappedtitle = ''

                    for titlepart in titlelist:
                        wrappedtitle += f'{titlepart}\n'

                    pages = []

                    for page in doujin.pages:
                        embed = Embed(title=f"Reading: {wrappedtitle}",
                                      color=Color.darker_gray())
                        embed.url = doujin.url

                        embed.set_image(url=page.url)
                        pages.append(embed)

                    paginator = BotEmbedPaginator(ctx, pages)
                    await paginator.run()

                except Exception as e:
                    print(e)
                    if str(e) == 'A doujin with the given id wasn\'t found':
                        await ctx.send(
                            '`Sorry senpai, but the doujin was not found!`')

            else:
                await ctx.send('`I don\'t think thats a code, senpai....`')
        else:
            await ctx.send(
                "`Sorry but senpai needs to be in a NSFW channel to read this :(`"
            )
Ejemplo n.º 7
0
    async def startquiz(self, ctx: commands.Context):
        await ctx.send("Collecting questions!")
        questions = await self.session.get_quiz(limit=5, category="linux")
        embed = Embed(title="Big Brain Time", color=Color.darker_gray())

        def check(m: Message):
            return m.channel == ctx.channel

        scoreboard = {}
        for q in questions:
            embed.clear_fields()
            desc = q.description + "\n" if q.description else ""
            desc += " ".join(["`" + t.name + "`" for t in q.tags]) + "\n"
            for i, a in enumerate(q.answers, 65):
                desc += chr(i) + ") " + a + "\n"
            embed.add_field(name=q.question, value=desc)
            correct_answers = []
            print(q.correct_answers)
            for i in range(q.correct_answers.count(True)):
                correct_answers.append(chr(65 + q.correct_answers.index(True)))
                q.correct_answers.remove(True)
                print(correct_answers)
            await ctx.send(embed=embed)
            unanswered = True
            while unanswered:
                try:
                    resp = await self.bot.wait_for("message", check=check, timeout=45)
                except:
                    return await ctx.send("No one answered")
                # await resp.delete()
                if resp.content.upper() in (correct_answers):
                    scoreboard[resp.author.id] = scoreboard.get(resp.author.id, 0) + 1
                    unanswered = False
        scores = "\n".join(
            [
                f"<@!{mid}>: {score}"
                for mid, score in sorted(scoreboard.items(), key=lambda i: i[1])
            ]
        )
        await ctx.send(
            embed=Embed(title="Results", description=scores, color=Color.green())
        )
Ejemplo n.º 8
0
    async def invite(self, ctx):
        if ctx.author.id in data['bannedids']:
            await ctx.send(
                ':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**'
            )
            return

        embed = Embed(
            title='Invite Nen',
            description=
            f'**Senpai can invite Nen into their own servers\' and help me grow!**\n**[Invite me senpai!]({data["invite"]} "Invite Nen to any server you want, senpai!")**',
            color=Color.darker_gray())

        embed.url = data['invite']
        embed.set_thumbnail(url=self.client.user.avatar_url)
        embed.set_footer(
            text=f'Requested by {ctx.author.name}#{ctx.author.discriminator}',
            icon_url=ctx.author.avatar_url)

        await ctx.send(embed=embed)
Ejemplo n.º 9
0
def get_color(rank: str = 'F') -> Color:
    """
    Gives `discord.Color` based on rank achieved in score

    :param rank: Rank achieved on score `str`
    :return: `discord.Color`
    """

    rank = rank.upper()
    if rank in ['SH', 'SSH']:
        return Color.light_grey()
    if rank in ['S', 'SS']:
        return Color.gold()
    if rank == 'A':
        return Color.green()
    if rank == 'B':
        return Color.blue()
    if rank == 'C':
        return Color.purple()
    if rank == 'D':
        return Color.red()

    return Color.darker_gray()
Ejemplo n.º 10
0
    async def help(self, ctx, *, param = ''):
        if ctx.author.id in data['bannedids']:
            await ctx.send(':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**')
            return
            
        embed = Embed()
        embed.color = Color.darker_gray()

        # n.help doujin
        if param == 'doujin': 
            embed.title = f'Nen sent senpai some help!\n\n{ht.doujin_title}'
            embed.description = ht.doujinhelp

        # n.help read
        elif param == 'read': 
            embed.title = f'Nen sent senpai some help!\n\n{ht.read_title}'
            embed.description = ht.readhelp

        # n.help misc
        elif param == 'misc': 
            embed.title = f'Nen sent senpai some help!\n\n{ht.misc_title}'
            embed.description = ht.mischelp

        elif param == 'reddit':
            embed.title = f'Nen sent senpai some help!\n\n{ht.reddit_title}'
            embed.description = ht.reddithelp

        # n.help
        else: 
            embed.title = f'Nen sent senpai some help!\n\n{ht.main_title}'
            embed.description = ht.mainhelp
            

        embed.set_footer(text = f'Requested by {ctx.author.name}#{ctx.author.discriminator}', icon_url = ctx.author.avatar_url)

        await ctx.send(embed=embed)
Ejemplo n.º 11
0
    async def info(self, ctx, code: int):
        if ctx.author.id in data['bannedids']:
            await ctx.send(
                ':no_entry_sign: **Sorry, but you are banned from using Nen!**\n **Please contact the owner on the official server to appeal for unban**'
            )
            return

        if isinstance(code, int):
            nsfwlogo = File("assets/images/nsfwlogo.png",
                            filename="nsfwlogo.png")

            try:
                doujin = nh.get_doujin(code)

                title = doujin.titles['pretty']
                engtitle = doujin.titles['english']
                japtitle = doujin.titles['japanese']

                language = ''

                for tag in doujin.tags:
                    if tag.type == 'language':
                        language += tag.name.capitalize() + ' \n'

                artist = ''

                for tag in doujin.tags:
                    if tag.type == 'artist':
                        artist += string.capwords(tag.name) + ' \n'

                pagecount = 0

                for page in doujin.pages:
                    pagecount += 1

                tagcount = 0

                for tag in doujin.tags:
                    tagcount += 1

                tagmsg = ''

                for tag in doujin.tags:
                    if tag.count > 999: tagnum = str(tag.count)[:-3] + 'k'
                    else: tagnum = str(tag.count)

                    tagmsg += f'**`{tag.name}: `**`{tagnum},`   '

                embed = Embed(
                    title=f'{title}',
                    description=
                    f'Full English Title: `{engtitle}`\nJapanese Title: `{japtitle}`\n\u200b',
                    color=Color.darker_gray())

                embed.url = doujin.url

                embed.add_field(name='Code', value=doujin.id, inline=True)
                embed.add_field(name='Media ID',
                                value=doujin.media_id,
                                inline=True)
                embed.add_field(name='Artist', value=artist, inline=True)
                embed.add_field(name='Language', value=language, inline=True)
                embed.add_field(name='Pages', value=pagecount, inline=True)
                embed.add_field(name='Favorites',
                                value=doujin.favorites,
                                inline=True)

                embed.add_field(name='Tags', value=tagmsg, inline=False)

                if ctx.channel.is_nsfw(
                ) or ctx.channel.id in data['pseudo_nsfw']:
                    embed.set_thumbnail(url=doujin.thumbnail)
                else:
                    embed.set_thumbnail(url='attachment://nsfwlogo.png')

                embed.set_footer(
                    text=
                    f'Requested by {ctx.author.name}#{ctx.author.discriminator}',
                    icon_url=ctx.author.avatar_url)

                if ctx.channel.is_nsfw(
                ) or ctx.channel.id in data['pseudo_nsfw']:
                    await ctx.send(embed=embed)
                else:
                    await ctx.send(file=nsfwlogo, embed=embed)

            except Exception as e:
                print(e)
                if str(e) == 'A doujin with the given id wasn\'t found':
                    await ctx.send(
                        '`Sorry senpai, but the doujin was not found!`')

        else:
            await ctx.send('`I don\'t think thats a code, senpai....`')