Beispiel #1
0
    async def debug(self, ctx: utils.CustomContext):
        """Base Command for the Debug cog."""

        description = list()
        description.append(
            f"This bot runs on Python {platform.python_version()} `[{platform.python_compiler()}]`\n")

        process = psutil.Process(os.getpid())
        memory_used = process.memory_info().rss / 1024 ** 2
        memory_info = psutil.virtual_memory()

        memory_fmt = (
            "The bot is currently using: "
            f"{memory_used:,.2f}/{memory_info.total / 1024 ** 2:,.2f} MB of memory"
        )
        description.append(memory_fmt)

        can_see_fmt = (
            "The bot can currently see: "
            f"{sum(g.member_count for g in self.bot.guilds):,} Members in {len(self.bot.guilds)} Guilds."
        )
        description.append(can_see_fmt)

        with ctx.embed() as embed:
            embed.description = "\n".join(description)
            await ctx.send(embed=embed)
 async def colours(self, ctx: utils.CustomContext, *, target: emoji_user):
     """Gets the 5 most relevant colours on a given emoji, attachment or member."""
     image = await self.get_image_url(ctx, target)
     async with ctx.timeit:
         img = await self.do_dagpi(image, "colors")
         with ctx.embed() as e:
             e.set_image(url=f"attachment://{img.filename}")
             await ctx.send(file=img, embed=e)
 async def wanted(self, ctx: utils.CustomContext, *, target: emoji_user):
     """Puts a given emoji, attachment or member on a wanted poster."""
     image = await self.get_image_url(ctx, target)
     async with ctx.timeit:
         img = await self.do_dagpi(image, "wanted")
         with ctx.embed() as e:
             e.set_image(url=f"attachment://{img.filename}")
             await ctx.send(file=img, embed=e)
 async def solarize(self, ctx: utils.CustomContext, *, target: emoji_user):
     """Applies a solarize effect to a given emoji, attachment or member."""
     image = await self.get_image(ctx, target)
     async with ctx.timeit:
         img = await Manipulation.solarize(image)
         file = discord.File(img, "travis_bott_solarize.png")
         with ctx.embed() as e:
             e.set_image(url="attachment://travis_bott_solarize.png")
             await ctx.send(file=file, embed=e)
 async def swirl(self, ctx: utils.CustomContext, amount: Optional[int], *, target: emoji_user):
     """Swirls a given attachment, emoji or member."""
     image = await self.get_image(ctx, target)
     async with ctx.timeit:
         img = await Manipulation.swirl(BytesIO(image), amount or 90)
         file = discord.File(img, "travis_bott_swirl.png")
         with ctx.embed() as e:
             e.set_image(url="attachment://travis_bott_swirl.png")
             await ctx.send(file=file, embed=e)
 async def alwayshasbeen(self, ctx: utils.CustomContext, *, text: Optional[str]):
     """It always has been..."""
     text = text or "I'm dumb and didn't put any text..."
     async with ctx.timeit:
         img = await Manipulation.alwayshasbeen(text)
         file = discord.File(img, "travis_bott_ahb.png")
         with ctx.embed() as e:
             e.set_image(url="attachment://travis_bott_ahb.png")
             await ctx.send(file=file, embed=e)
 async def brighten(self, ctx: utils.CustomContext, amount: Optional[int], *, target: emoji_user):
     """Applies a brighten effect to a given emoji, attachment or member."""
     amount = 250 if amount > 250 else amount
     image = await self.get_image(ctx, target)
     async with ctx.timeit:
         img = await Manipulation.brighten(image, amount or 50)
         file = discord.File(img, "travis_bott_brighten.png")
         with ctx.embed() as e:
             e.set_image(url="attachment://travis_bott_brighten.png")
             await ctx.send(file=file, embed=e)
 async def facetime(self, ctx: utils.CustomContext, target: emoji_user):
     """Gives a neat facetime effect to a given emoji, attachment or member."""
     image = await self.get_image(ctx, target)
     async with ctx.timeit:
         thumbnail = await ctx.author.avatar_url_as(format="png").read()
         img = await Manipulation.facetime(image, thumbnail)
         file = discord.File(img, "travis_bott_ft.png")
         with ctx.embed() as e:
             e.set_image(url="attachment://travis_bott_ft.png")
             await ctx.send(file=file, embed=e)
Beispiel #9
0
    async def vote(self, ctx: utils.CustomContext):
        """Gives the link to vote for Travis"""

        fmt = (
            f"[Click here to vote for Travis Bott on top.gg](https://top.gg/bot/706530005169209386)\n"
            f"[Click here to vote for Travis Bott on discord.boats](https://discord.boats/bot/706530005169209386)\n"
            "If you genuinely enjoy the bot make sure to leave an honest review, thank you for using Travis Bott on top.gg."
        )

        with ctx.embed() as embed:
            embed.description = fmt
            await ctx.send(embed=embed)
Beispiel #10
0
    async def privacy(self, ctx: utils.CustomContext):
        """Sends the bots privacy policy statement."""

        fmt = (
            "Travis Bott doesn't store much data, but here is what it *does* store and why:\n"
            "User ID's get stored for numerous things such as cookie clicker leaderboards, "
            "When someone gets muted in a server etc. Guild ID's get stored also for things "
            "such as configuration purposes e.g. prefixes and mute role ids. Message ID's get "
            "stored so we're able to corrolate them to roles for our verification command.\n"
            "If you have any questions or would like any of your data removed, contact kal#1806 "
            "via discord, either add them or via the support server.")

        with ctx.embed() as e:
            e.description = fmt
            await ctx.send(embed=e)
Beispiel #11
0
    async def dev_stats(self, ctx: utils.CustomContext):
        """Gives some stats on the bot."""

        p = pathlib.Path('./')
        cm = cr = fn = cl = ls = fc = 0
        for f in p.rglob('*.py'):
            if str(f).startswith("env"):
                continue
            fc += 1
            with f.open() as of:
                for l in of.readlines():
                    l = l.strip()
                    if l.startswith('class'):
                        cl += 1
                    if l.startswith('def'):
                        fn += 1
                    if l.startswith('async def'):
                        cr += 1
                    if '#' in l:
                        cm += 1
                    ls += 1

        code_count = (f"Files: {fc}\n"
                      f"Lines: {ls}\n"
                      f"Classes: {cl}\n"
                      f"Functions: {fn}\n"
                      f"Coroutines: {cr}\n"
                      f"Comments: {cm}\n")
        server_count = sum(1 for g in self.bot.guilds)
        user_count = sum(g.member_count for g in self.bot.guilds)
        command_count = sum(1 for cmd in self.bot.walk_commands())
        ping = round(self.bot.latency * 1000)
        uptime = utils.format_time(self.bot.start_time)

        fields = [["Server Count", server_count, True],
                  ["User Count", user_count, True],
                  ["Command Count", command_count, True],
                  ["Command Usage (last restart)", self.bot.cmd_usage, True],
                  ["Ping", ping, True], ["Uptime", uptime["precise"], True],
                  ["Code Count", f"```\n{code_count}```", False]]

        with ctx.embed() as embed:
            [embed.add_field(name=n, value=v, inline=i) for n, v, i in fields]
            await ctx.send(embed=embed)
Beispiel #12
0
    async def ping(self, ctx: utils.CustomContext):
        """Get the bots ping."""

        typing_start = time.perf_counter()
        await ctx.trigger_typing()
        typing_time_ms = ("Typing Latency",
                          (time.perf_counter() - typing_start) * 1000)

        db_start = time.perf_counter()
        await ctx.db.fetch("SELECT 1;")
        db_time_ms = ("DB Latency", (time.perf_counter() - db_start) * 1000)

        heartbeat_ms = ("Heartbeat Latency", self.bot.latency * 1000)

        with ctx.embed() as e:
            for typeof, result in typing_time_ms, db_time_ms, heartbeat_ms:
                e.add_field(name=typeof,
                            value=f"{result:,.2f} ms",
                            inline=False)

            await ctx.send(embed=e)
Beispiel #13
0
    async def status(self, ctx: utils.CustomContext):
        """Gets the status of how Travis is doing right now."""

        with ctx.embed() as e:
            summary = []
            latency = round(self.bot.latency * 1000, 2)
            summary.append(f"Latency: {latency} ms.")

            async with self.bot.session.get(
                    "https://www.travisbott.rocks/") as r:
                if r.status != 200:
                    summary.append(
                        f"Website is returning a {r.status} status.")
                else:
                    summary.append(f"Website is fully operational.")

            summary.append(
                "Well the bot is online since you can see this message \N{THINKING FACE}."
            )

            e.description = "\n".join(summary)
            await ctx.send(embed=e)