diff options
| author | 2020-12-08 10:21:41 +0200 | |
|---|---|---|
| committer | 2020-12-08 10:21:41 +0200 | |
| commit | 8b41a7678d175de69ae6bf72e6a9f6e7036e1968 (patch) | |
| tree | d979b5a5a90d33d17481eca381ea941a2caf78b6 | |
| parent | Used a list of tuples for on_message instead (diff) | |
Add file path to codeblock
| -rw-r--r-- | bot/exts/info/code_snippets.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bot/exts/info/code_snippets.py b/bot/exts/info/code_snippets.py index 1bb00b677..f807fa9a7 100644 --- a/bot/exts/info/code_snippets.py +++ b/bot/exts/info/code_snippets.py @@ -188,9 +188,16 @@ class CodeSnippets(Cog): if not is_valid_language: language = '' + # Adds a label showing the file path to the snippet + if start_line == end_line: + ret = f'`{file_path}` line {start_line}\n' + else: + ret = f'`{file_path}` lines {start_line} to {end_line}\n' + if len(required) != 0: - return f'```{language}\n{required}```\n' - return '' + return f'{ret}```{language}\n{required}```\n' + # Returns an empty codeblock if the snippet is empty + return f'{ret}``` ```\n' def __init__(self, bot: Bot): """Initializes the cog's bot.""" |