Ejemplo n.º 1
0
def edir(o):
    """send embed of an object's attributes, with type notation"""
    e = Embed(title=utils.getFullname(o))
    attrs = [eformat(n, v) for n, v in utils.ddir(o).items()]
    pageLen = math.ceil(len(attrs) / 3)
    for page in utils.chunkList(attrs, pageLen):
        e.add_field(value="\n".join(page))
    return e
Ejemplo n.º 2
0
    async def objs(self, ctx):
        """Get a list of the various objects SizeBot accepts."""
        objectunits = []
        for obj in objs.objects:
            objectunits += obj.singularNames

        objectunits.sort()

        embed = Embed(title=f"Objects [SizeBot {__version__}]")

        for n, units in enumerate(
                utils.chunkList(objectunits, math.ceil(len(objectunits) / 3))):
            embed.add_field(name="Objects" if n == 0 else "\u200b",
                            value="\n".join(units))

        await ctx.send(embed=embed)
Ejemplo n.º 3
0
    async def units(self, ctx):
        """Get a list of the various units SizeBot accepts."""
        heightobjectunits = [su.unit for su in SV._systems["o"]._systemunits]
        weightobjectunits = [su.unit for su in WV._systems["o"]._systemunits]

        heightunits = [
            str(u) for u in sorted(SV._units) if u not in heightobjectunits
        ]
        weightunits = [
            str(u) for u in sorted(WV._units) if u not in weightobjectunits
        ]

        embed = Embed(title=f"Units [SizeBot {__version__}]")

        for n, units in enumerate(
                utils.chunkList(heightunits, math.ceil(len(heightunits) / 3))):
            embed.add_field(name="Height" if n == 0 else "\u200b",
                            value="\n".join(units))

        for n, units in enumerate(
                utils.chunkList(weightunits, math.ceil(len(weightunits) / 3))):
            embed.add_field(name="Weight" if n == 0 else "\u200b",
                            value="\n".join(units))

        await ctx.send(embed=embed)
Ejemplo n.º 4
0
 async def leaderboard(self, ctx):
     """See who's the most agreeable!"""
     now = datetime.now(tzlocal())
     tracker = ThisTracker.load()
     trackerlist = sorted(tracker.points.items(), key=lambda i: i[1], reverse= True)
     embed = Embed(title=f"The Most Agreeable Users", color=0x31eff9)
     embed.set_author(name=f"SizeBot {__version__}")
     messagetosend = ""
     totalpoints = sum(tracker.points.values())
     for userid, points in trackerlist[0:10]:
         messagetosend += f"**{self.bot.get_user(userid).display_name}**: {points}\n"
     embed.add_field(name=f"{totalpoints} total agreements", value=messagetosend.strip(), inline=False)
     embed.set_footer(text=f"{now.strftime('%d %b %Y %H:%M:%S %Z')}")
     await ctx.send(embed = embed)
Ejemplo n.º 5
0
    async def send_command_help(self, ctx, cmd):
        """Sends help for a command.

        Help

        {prefix}{cmd.name} {cmd.usage (or autogenerated signature)}

        {cmd.description (optional)}

        {cmd.help (docstring, optional)}

        Aliases:
        alias1, alias2
        """
        signature = f"{ctx.prefix}{cmd.name} {cmd.signature}"

        descriptionParts = []
        if cmd.description:
            descriptionParts.append(cmd.description)
        if cmd.help:
            descriptionParts.append(cmd.help)
        description = ""
        if "is_owner" in repr(cmd.checks):
            description += ":rotating_light: **THIS COMMAND IS FOR BOT OWNERS ONLY** :rotating_light:\n"
        if "is_mod" in repr(cmd.checks):
            description += ":rotating_light: **THIS COMMAND IS FOR SERVER MODS ONLY** :rotating_light:\n"
        if "guild_only" in repr(cmd.checks):
            description += "*This command can only be run in a server, and not in DMs.*\n"
        description += "\n\n".join(descriptionParts).replace("&", conf.prefix)

        embed = Embed(title=signature, description=description).set_author(
            name=f"Help [SizeBot {__version__}]")

        if cmd.aliases:
            embed.add_field(name="**Aliases:**",
                            value=", ".join(cmd.aliases),
                            inline=False)

        await ctx.send(embed=embed)
Ejemplo n.º 6
0
    def getStatsEmbed(self, multiplier=1):
        embed = Embed()
        embed.set_author(name=f"SizeBot {__version__}")

        if self.height:
            embed.add_field(
                name="Height",
                value=f"**{SV(self.height * multiplier):,.3mu}** tall\n")
        if self.length:
            embed.add_field(
                name="Length",
                value=f"**{SV(self.length * multiplier):,.3mu}** long\n")
        if self.width:
            embed.add_field(
                name="Width",
                value=f"**{SV(self.width * multiplier):,.3mu}** wide\n")
        if self.diameter:
            embed.add_field(
                name="Diameter",
                value=f"**{SV(self.diameter * multiplier):,.3mu}** across\n")
        if self.depth:
            embed.add_field(
                name="Depth",
                value=f"**{SV(self.depth * multiplier):,.3mu}** deep\n")
        if self.thickness:
            embed.add_field(
                name="Thickness",
                value=f"**{SV(self.depth * multiplier):,.3mu}** thick\n")
        if self.weight:
            embed.add_field(
                name="Weight",
                value=f"**{WV(self.weight * (multiplier ** 3)):,.3mu}**")

        if self.image:
            embed.set_image(self.image)

        return embed
Ejemplo n.º 7
0
    async def color(self, ctx, arg1: str, *, arg2: str = None):
        """Get info about a color."""
        outmessage = await ctx.send(emojis.loading)

        url = "http://thecolorapi.com"
        schemeurl = "https://www.thecolorapi.com/scheme?hex={0}&format=html"

        # Default to hex.
        if not arg2:
            colortype = "hex"
            colorvalue = arg1
        else:
            colortype = arg1.lower()
            colorvalue = arg2

        colorvalues = re_dividers.split(colorvalue)

        # Make the color value we're putting into the URL be formatted in a way it likes,
        # and also catch any malformed arguments.
        if colortype == "hex":
            # HEX
            match_hex = re_hex.match(colorvalue)
            if not match_hex:
                await outmessage.edit(
                    content=f"`{colorvalue}` is not an accepted hex color.")
                return
            colorvalueout = match_hex.group(1)
        elif colortype == "rgb":
            # RGB
            if len(colorvalues) != 3:
                await outmessage.edit(
                    content=f"A {colortype} color can only have 3 parts.")
                return
            for value in colorvalues:
                if not re_digits.match(value):
                    await outmessage.edit(
                        content=
                        f"{value} is not a valid color part for a {colortype}-type color."
                    )
                    return
            colorvalueout = ",".join(colorvalues)
        elif colortype in ["hsl", "hsv"]:
            # HSL/HSV
            if len(colorvalues) != 3:
                await outmessage.edit(
                    content=f"A {colortype} color can only have 3 parts.")
                return
            if not re_digits.match(colorvalues[0]):
                await outmessage.edit(
                    content=
                    f"{value} is not a valid color part for a {colortype}-type color."
                )
                return
            for value in colorvalues[1:]:
                if not re_percent.match(value):
                    await outmessage.edit(
                        content=
                        f"{value} is not a valid color part for a {colortype}-type color."
                    )
                    return
            colorvalueout = ",".join(colorvalues)
        elif colortype in ["cmyk", "cymk"]:
            # CMYK
            colortype = "cmyk"
            if len(colorvalues) != 4:
                await outmessage.edit(
                    content=
                    f"A {colortype} color can only have between 3 and 4 parts."
                )
                return
            for value in colorvalues:
                if not re_percent.match(value):
                    await outmessage.edit(
                        content=
                        f"{value} is not a valid color part for a {colortype}-type color."
                    )
                    return
            colorvalueout = ",".join(colorvalues)
        else:
            # Invalid color type
            await outmessage.edit(
                content=
                f"`{colortype}` is not an accepted color type.\nAccepted types are hex, rgb, hsv, hsl, or cymk."
            )
            return

        r = requests.get(url + "/id?" + colortype + "=" + colorvalueout)
        colorjson = r.json()

        if r.status_code != 200:
            await outmessage.edit(
                emojis.warning +
                "The Color API is not working as expected. Please try again later."
            )

        hexstring = colorjson["hex"]["clean"]
        hexvalue = int(hexstring, 16)
        colorscheme = schemeurl.format(hexstring)
        colorname = colorjson["name"]["value"]
        printhex = colorjson["hex"]["value"]
        colorrgb = colorjson["rgb"]["value"]
        colorhsl = colorjson["hsl"]["value"]
        colorhsv = colorjson["hsv"]["value"]
        colorcmyk = colorjson["cmyk"]["value"]

        embed = Embed(title=f"{colorname} [{printhex}]",
                      description="",
                      color=hexvalue,
                      url=colorscheme)
        embed.set_author(name=f"SizeBot {__version__} [{conf.prefix}color]",
                         icon_url=coloricon)
        embed.add_field(name="Hex Value", value=printhex, inline=True)
        embed.add_field(name="RGB Value", value=colorrgb, inline=True)
        embed.add_field(name="HSL Value", value=colorhsl, inline=True)
        embed.add_field(name="HSV Value", value=colorhsv, inline=True)
        embed.add_field(name="CMYK Value", value=colorcmyk, inline=True)
        embed.set_footer(text=f"Requested by {ctx.author.display_name}")

        embed.set_image(
            url=f"http://www.singlecolorimage.com/get/{hexstring}/400x200.png")

        await outmessage.edit(content="", embed=embed)
Ejemplo n.º 8
0
    async def send_summary_help(self, ctx):
        """Sends help summary.

        Help

        Commands

        {cmd.name} - {cmd.brief (or first line of cmd.help)}
        {cmd.name} - {cmd.brief (or first line of cmd.help)}
        ...
        """

        embed = Embed(title=f"Help [SizeBot {__version__}]")
        embed.description = "*Select an emoji to see details about a category.*"
        embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)

        # Get all non-hidden commands, sorted by name
        commands = (c for c in ctx.bot.commands if not c.hidden)
        commands = sorted(commands, key=lambda c: c.name)

        # Divide commands into categories
        commands_by_cat = {cat.cid: [] for cat in categories}

        for c in commands:
            cmd_category = c.category or "misc"
            if cmd_category not in commands_by_cat:
                logger.warn(
                    f"Command category {cmd_category!r} does not exist.")
                cmd_category = "misc"
            commands_by_cat[cmd_category].append(c)

        fields_text = ""

        for cat in categories:
            cat_cmds = commands_by_cat.get(cat.cid, [])
            if not cat_cmds:
                logger.warn(f"Command category {cat.cid!r} is empty.")
                continue
            fields_text += f"\n\n**{cat.emoji} {cat.name}**\n" + (", ".join(
                f"`{c.name}`" for c in cat_cmds))

        embed.add_field(value=fields_text)

        categoryoptions = {cat.emoji: cat for cat in categories}

        reactionmenu, answer = await Menu.display(ctx,
                                                  categoryoptions.keys(),
                                                  cancel_emoji=emojis.cancel,
                                                  initial_embed=embed,
                                                  delete_after=False)

        if answer in categoryoptions.keys():
            selectedcategory = categoryoptions[answer]
            deepembed = Embed(
                title=f"{selectedcategory.name} Help [SizeBot {__version__}]")
            deepembed.set_author(name=ctx.author.name,
                                 icon_url=ctx.author.avatar_url)
            cat_cmds = commands_by_cat.get(selectedcategory.cid, [])
            fields_text = f"**{selectedcategory.emoji}{selectedcategory.name}**\n\n" + (
                "\n".join(f"`{c.name}` {c.alias_string}\n{c.short_doc}"
                          for c in cat_cmds))
            deepembed.add_field(value=fields_text)
            await reactionmenu.message.edit(embed=deepembed)
Ejemplo n.º 9
0
 async def about(self, ctx):
     """Get the credits and some facts about SizeBot."""
     now = datetime.now()
     embed = Embed(title="SizeBot3½",
                   description="Think of a new slogan!",
                   color=0x11cccc)
     embed.set_author(name="DigiDuncan")
     embed.set_image(
         url=
         "https://cdn.discordapp.com/attachments/650460192009617433/698529527965417552/sizebotlogot.png"
     )
     embed.add_field(
         name="Credits",
         value=(
             "**Coding Assistance** *by Natalie*\n"
             "**Additional Equations** *by Benyovski and Arceus3251*\n"
             "**Alpha Tested** *by AWK_*\n"
             "**Beta Tested** *by Kelly, worstgender, and Arceus3251*\n"),
         inline=False)
     embed.add_field(
         name="Servers",
         value=
         ("**[SizeDev](https://discord.gg/j2WpxS)**: support and beta testing for SizeBot and other bots, like Chocola's [*Mei.*](https://chocola.codes/)\n"
          "**[Size Matters](https://discord.gg/UbMxrW)**: a size server moderated by DigiDuncan and others *(see below)*"
          ),
         inline=False)
     embed.add_field(
         name="Technical Details",
         value=
         "Written in Python 3.6, and slowly upgraded to 3.8. Originally written using Atom, and now Visual Studio Code. External libraries used are `discord.py` (rewrite version), `digiformatter` (my personal terminal-formatting library), and various dependencies you can find on the GitHub page.",
         inline=False)
     embed.add_field(
         name="Special Thanks",
         value=
         ("**Special thanks** *to Reol, jyubari, and Memekip for making the Size Matters server, and Yukio and SpiderGnome for helping moderate it.*\n"
          "**Special thanks** *to Chocola, the creator of Mei and Arachne, for inspiration and moral support.*\n"
          "**Special thanks** *to the discord.py Community Discord for helping with code.*\n"
          f"**Special thanks** *to the {userdb.count()} users of SizeBot3½.*"
          ),
         inline=False)
     embed.add_field(
         name="Testimonials",
         value=(
             "\"She [SizeBot] is beautiful.\" *-- GoddessArete*\n"
             "\"I want to put SizeBot in charge of the world government.\"* -- AWK*\n"
             "\"Um... I like it?\" *-- Goddess Syn*\n"
             # "\"Fix the bot.\" *-- Natalie*"
             "\"I am the only person who has accidentally turned my fetish into a tech support job.\" *-- DigiDuncan*\n"
             "\"\"I am the only person who has accidentally turned my fetish into a tech support job.\" *-- DigiDuncan*\" *-- Chocola*"
         ),
         inline=False)
     embed.set_footer(
         text=f"Version {__version__} | {now.strftime('%d %b %Y')}")
     await ctx.send(embed=embed)
Ejemplo n.º 10
0
 def toEmbed(self):
     embed = Embed(title=f"Stats for {self.nickname}", color=0x31eff9)
     embed.set_author(name=f"SizeBot {__version__}")
     embed.add_field(
         name="Current Height",
         value=f"{self.height:,.3mu}\n*{self.formattedscale} scale*",
         inline=True)
     embed.add_field(
         name="Current Weight",
         value=f"{self.weight:,.3mu}\n*{self.formattedweightscale} scale*",
         inline=True)
     embed.add_field(name="Foot Length",
                     value=f"{self.footlength:.3mu}\n({self.shoesize})",
                     inline=True)
     embed.add_field(name="Foot Width",
                     value=format(self.footwidth, ",.3mu"),
                     inline=True)
     embed.add_field(name="Toe Height",
                     value=format(self.toeheight, ",.3mu"),
                     inline=True)
     embed.add_field(name="Shoeprint Depth",
                     value=format(self.shoeprintdepth, ",.3mu"),
                     inline=True)
     embed.add_field(name="Pointer Finger Length",
                     value=format(self.pointerlength, ",.3mu"),
                     inline=True)
     embed.add_field(name="Thumb Width",
                     value=format(self.thumbwidth, ",.3mu"),
                     inline=True)
     embed.add_field(name="Nail Thickness",
                     value=format(self.nailthickness, ",.3mu"),
                     inline=True)
     embed.add_field(name="Fingerprint Depth",
                     value=format(self.fingerprintdepth, ",.3mu"),
                     inline=True)
     embed.add_field(name="Clothing Thread Thickness",
                     value=format(self.threadthickness, ",.3mu"),
                     inline=True)
     if self.hairlength:
         embed.add_field(name="Hair Length",
                         value=format(self.hairlength, ",.3mu"),
                         inline=True)
     if self.taillength:
         embed.add_field(name="Tail Length",
                         value=format(self.taillength, ",.3mu"),
                         inline=True)
     embed.add_field(name="Hair Width",
                     value=format(self.hairwidth, ",.3mu"),
                     inline=True)
     embed.add_field(name="Eye Width",
                     value=format(self.eyewidth, ",.3mu"),
                     inline=True)
     embed.add_field(
         name="Walk Speed",
         value=
         f"{self.walkperhour:,.1M} per hour\n({self.walkperhour:,.1U} per hour)",
         inline=True)
     embed.add_field(
         name="Run Speed",
         value=
         f"{self.runperhour:,.1M} per hour\n({self.runperhour:,.1U} per hour)",
         inline=True)
     embed.add_field(inline=False)
     embed.add_field(
         name="Character Bases",
         value=f"{self.baseheight:,.3mu} | {self.baseweight:,.3mu}",
         inline=False)
     embed.set_footer(
         text=
         f"An average person would look {self.avgheightcomp:,.3mu}, and weigh {self.avgweightcomp:,.3mu} to you. You'd have to look {self.avglookdirection} {self.avglookangle:.0f}° to see them."
     )
     return embed
Ejemplo n.º 11
0
 def toEmbed(self):
     embed = Embed(
         title=
         f"Comparison of {self.big.nickname} and {self.small.nickname}",
         description="",
         color=0x31eff9,
         url=self.url)
     embed.set_author(name=f"SizeBot {__version__}", icon_url=compareicon)
     embed.add_field(
         name=f"{emojis.comparebigcenter} **{self.big.nickname}**",
         value=
         (f"{emojis.blank}{emojis.blank} **Height:** {self.big.height:,.3mu}\n"
          f"{emojis.blank}{emojis.blank} **Weight:** {self.big.weight:,.3mu}\n"
          ),
         inline=True)
     embed.add_field(
         name=f"{emojis.comparesmallcenter} **{self.small.nickname}**",
         value=
         (f"{emojis.blank}{emojis.blank} **Height:** {self.small.height:,.3mu}\n"
          f"{emojis.blank}{emojis.blank} **Weight:** {self.small.weight:,.3mu}\n"
          ),
         inline=True)
     embed.add_field(value=(
         f"{emojis.comparebig} represents how {emojis.comparebigcenter} **{self.big.nickname}** looks to {emojis.comparesmallcenter} **{self.small.nickname}**.\n"
         f"{emojis.comparesmall} represents how {emojis.comparesmallcenter} **{self.small.nickname}** looks to {emojis.comparebigcenter} **{self.big.nickname}**."
     ),
                     inline=False)
     embed.add_field(
         name="Height",
         value=(f"{emojis.comparebig}{self.bigToSmall.height:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.height:,.3mu}"),
         inline=False)
     embed.add_field(
         name="Weight",
         value=(f"{emojis.comparebig}{self.bigToSmall.weight:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.weight:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Foot Length",
         value=
         (f"{emojis.comparebig}{self.bigToSmall.footlength:,.3mu} ({self.bigToSmall.shoesize})\n"
          f"{emojis.comparesmall}{self.smallToBig.footlength:,.3mu} ({self.smallToBig.shoesize})"
          ),
         inline=True)
     embed.add_field(
         name="Foot Width",
         value=(f"{emojis.comparebig}{self.bigToSmall.footwidth:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.footwidth:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Toe Height",
         value=(f"{emojis.comparebig}{self.bigToSmall.toeheight:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.toeheight:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Shoeprint Depth",
         value=(
             f"{emojis.comparebig}{self.bigToSmall.shoeprintdepth:,.3mu}\n"
             f"{emojis.comparesmall}{self.smallToBig.shoeprintdepth:,.3mu}"
         ),
         inline=True)
     embed.add_field(
         name="Pointer Finger Length",
         value=(
             f"{emojis.comparebig}{self.bigToSmall.pointerlength:,.3mu}\n"
             f"{emojis.comparesmall}{self.smallToBig.pointerlength:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Thumb Width",
         value=(f"{emojis.comparebig}{self.bigToSmall.thumbwidth:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.thumbwidth:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Nail Thickness",
         value=(
             f"{emojis.comparebig}{self.bigToSmall.nailthickness:,.3mu}\n"
             f"{emojis.comparesmall}{self.smallToBig.nailthickness:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Fingerprint Depth",
         value=
         (f"{emojis.comparebig}{self.bigToSmall.fingerprintdepth:,.3mu}\n"
          f"{emojis.comparesmall}{self.smallToBig.fingerprintdepth:,.3mu}"),
         inline=True)
     if self.bigToSmall.hairlength or self.smallToBig.hairlength:
         hairfield = ""
         if self.bigToSmall.hairlength:
             hairfield += f"{emojis.comparebig}{self.bigToSmall.hairlength:,.3mu}\n"
         if self.smallToBig.hairlength:
             hairfield += f"{emojis.comparebig}{self.smallToBig.hairlength:,.3mu}\n"
         hairfield = hairfield.strip()
         embed.add_field(name="Hair Length", value=hairfield, inline=True)
     if self.bigToSmall.taillength or self.smallToBig.hairlength:
         tailfield = ""
         if self.bigToSmall.taillength:
             tailfield += f"{emojis.comparebig}{self.bigToSmall.taillength:,.3mu}\n"
         if self.smallToBig.taillength:
             tailfield += f"{emojis.comparebig}{self.smallToBig.taillength:,.3mu}\n"
         tailfield = tailfield.strip()
         embed.add_field(name="Tail Length", value=tailfield, inline=True)
     embed.add_field(
         name="Hair Width",
         value=(f"{emojis.comparebig}{self.bigToSmall.hairwidth:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.hairwidth:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Eye Width",
         value=(f"{emojis.comparebig}{self.bigToSmall.eyewidth:,.3mu}\n"
                f"{emojis.comparesmall}{self.smallToBig.eyewidth:,.3mu}"),
         inline=True)
     embed.add_field(
         name="Walk Speed",
         value=
         (f"{emojis.comparebig}{self.bigToSmall.walkperhour:,.1M} per hour ({self.bigToSmall.walkperhour:,.1U} per hour)\n"
          f"{emojis.comparesmall}{self.smallToBig.walkperhour:,.1M} per hour ({self.smallToBig.walkperhour:,.1U} per hour)"
          ),
         inline=True)
     embed.add_field(
         name="Run Speed",
         value=
         (f"{emojis.comparebig}{self.bigToSmall.runperhour:,.1M} per hour ({self.bigToSmall.runperhour:,.1U} per hour)\n"
          f"{emojis.comparesmall}{self.smallToBig.runperhour:,.1M} per hour ({self.smallToBig.runperhour:,.1U} per hour)"
          ),
         inline=True)
     embed.set_footer(text=(
         f"{self.small.nickname} would have to look {self.lookdirection} {self.lookangle:.0f}° to look at {self.big.nickname}'s face.\n"
         f"{self.big.nickname} is {self.multiplier:,.3}x taller than {self.small.nickname}."
     ))
     return embed