From 78079355716a15444e6bd05c312a68e8a48348cd Mon Sep 17 00:00:00 2001 From: nex Date: Mon, 28 Aug 2023 21:57:24 +0100 Subject: [PATCH] Fix SLOC counter --- cogs/events.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cogs/events.py b/cogs/events.py index 2bc607e..2cfdbae 100644 --- a/cogs/events.py +++ b/cogs/events.py @@ -322,6 +322,12 @@ class Events(commands.Cog): root = Path.cwd() root_files = list(root.glob("**/*.py")) root_files.append(root / "main.py") + root_files = list( + filter( + lambda f: "venv" not in f.parents and "venv" not in f.parts, + root_files + ) + ) lines = 0 for file in root_files: @@ -334,7 +340,7 @@ class Events(commands.Cog): if not line or line.startswith("#"): continue lines += 1 - return lines + return lines, len(root_files) if not message.guild: return @@ -468,7 +474,7 @@ class Events(commands.Cog): "file": discord.File(assets / "boris.jpeg") }, r"\W?(s(ource\w)?)?l(ines\s)?o(f\s)?c(ode)?(\W)?": { - "content": lambda: "I have {:,} lines of source code!".format(get_sloc_count()) + "content": lambda: "I have {:,} lines of source code across {:,} files!".format(*get_sloc_count()) } } # Stop responding to any bots