예제 #1
0
    async def stats(self, ctx: commands.Context) -> None:
        """Get the information and current uptime of the bot."""
        embed = Embed(
            title="Bot Stats",
            color=Colours.green,
        )

        embed.set_thumbnail(url=self.bot.user.display_avatar.url)

        uptime = humanize.precisedelta(
            datetime.utcnow().timestamp() - self.bot.launch_time
        )

        fields = {
            "Python version": python_version(),
            "Disnake version": __version__,
            "Uptime": uptime,
        }

        for name, value in list(fields.items()):
            embed.add_field(name=name, value=value, inline=False)
        await ctx.send(content=ctx.author.mention, embed=embed)
예제 #2
0
    async def source_command(self,
                             ctx: commands.Context,
                             *,
                             source_item: typing.Optional[str] = None) -> None:
        """Displays information about the bot's source code."""
        if source_item is None:
            embed = Embed(title="Gurkbot's GitHub Repository")
            embed.add_field(name="Repository",
                            value=f"[Go to GitHub]({BOT_REPO_URL})")
            embed.set_thumbnail(url=self.bot.user.display_avatar.url)
            await ctx.send(embed=embed)
            return
        elif not ctx.bot.get_command(source_item):
            raise commands.BadArgument(
                f"Unable to convert `{source_item}` to valid command or Cog.")

        github_source = _source.Source(self.bot.http_session,
                                       self.bot.user.display_avatar.url)
        embed = await github_source.inspect(
            cmd=ctx.bot.get_command(source_item))

        await ctx.send(embed=embed)
예제 #3
0
            title=split(title),
            description=split(description),
        )

        image_url = urL_or_file(image)
        thumbnail_url = urL_or_file(thumbnail)
        files = []

        if isinstance(image_url, str):
            embed.set_image(url=image_url)
        else:
            embed.set_image(file=image_url)
            files.append(image_url)

        if isinstance(thumbnail_url, str):
            embed.set_thumbnail(url=thumbnail_url)
        else:
            embed.set_thumbnail(file=thumbnail_url)
            files.append(thumbnail_url)

        embed.set_footer(text=split(footer))

        wb.send(
            content=split(text),
            embed=embed,
            files=files,
            username=data.username,
            avatar_url=data.avatar_url,
        )

        print(f"\nText and embed sent successfully.")