def github_source(self, ctx, *, command: BotCommand = None):
"""Displays the github link for the source code of a particular command.
Keep in mind that although this is less spammy. It may be inaccurate or
even in a completely different place if last-minute changes were applied
to the code and weren't pushed to GitHub.
If you truly want the most accurate code, use `{prefix}source`.
"""
source_url = f'https://github.com/Ikusaba-san/Chiaki-Nanami/tree/dev'
if command is None:
return await ctx.send(source_url)
src = command.callback.__code__
lines, firstlineno = inspect.getsourcelines(src)
lastline = firstlineno + len(lines) - 1
# We don't use the built-in commands so we can eliminate this branch
location = os.path.relpath(src.co_filename).replace('\\', '/')
url = f'<{source_url}/{location}#L{firstlineno}-L{lastline}>'
await ctx.send(url)
评论列表
文章目录