diff options
Diffstat (limited to 'bot/exts/core/source.py')
-rw-r--r-- | bot/exts/core/source.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bot/exts/core/source.py b/bot/exts/core/source.py index f771eaca..7c67bcb5 100644 --- a/bot/exts/core/source.py +++ b/bot/exts/core/source.py @@ -1,15 +1,17 @@ import inspect from pathlib import Path -from typing import Optional from discord import Embed from discord.ext import commands from bot.bot import Bot -from bot.constants import Channels, Source, WHITELISTED_CHANNELS +from bot.constants import Channels, WHITELISTED_CHANNELS from bot.utils.converters import SourceConverter, SourceType from bot.utils.decorators import whitelist_override +GITHUB_BOT_URL = "https://github.com/python-discord/sir-lancebot" +BOT_AVATAR_URL = "https://avatars1.githubusercontent.com/u/9919" + class BotSource(commands.Cog): """Displays information about the bot's source code.""" @@ -20,15 +22,15 @@ class BotSource(commands.Cog): """Display information and a GitHub link to the source code of a command, tag, or cog.""" if not source_item: embed = Embed(title="Sir Lancebot's GitHub Repository") - embed.add_field(name="Repository", value=f"[Go to GitHub]({Source.github})") - embed.set_thumbnail(url=Source.github_avatar_url) + embed.add_field(name="Repository", value=f"[Go to GitHub]({GITHUB_BOT_URL})") + embed.set_thumbnail(url=BOT_AVATAR_URL) await ctx.send(embed=embed) return embed = await self.build_embed(source_item) await ctx.send(embed=embed) - def get_source_link(self, source_item: SourceType) -> tuple[str, str, Optional[int]]: + def get_source_link(self, source_item: SourceType) -> tuple[str, str, int | None]: """ Build GitHub link of source item, return this link, file location and first line number. @@ -58,11 +60,11 @@ class BotSource(commands.Cog): file_location = Path(filename).relative_to(Path.cwd()).as_posix() - url = f"{Source.github}/blob/main/{file_location}{lines_extension}" + url = f"{GITHUB_BOT_URL}/blob/main/{file_location}{lines_extension}" return url, file_location, first_line_no or None - async def build_embed(self, source_object: SourceType) -> Optional[Embed]: + async def build_embed(self, source_object: SourceType) -> Embed | None: """Build embed based on source object.""" url, location, first_line = self.get_source_link(source_object) @@ -74,7 +76,7 @@ class BotSource(commands.Cog): description = source_object.description.splitlines()[0] embed = Embed(title=title, description=description) - embed.set_thumbnail(url=Source.github_avatar_url) + embed.set_thumbnail(url=BOT_AVATAR_URL) embed.add_field(name="Source Code", value=f"[Go to GitHub]({url})") line_text = f":{first_line}" if first_line else "" embed.set_footer(text=f"{location}{line_text}") |