aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2023-03-06 00:54:04 +0200
committerGravatar GitHub <[email protected]>2023-03-05 22:54:04 +0000
commit8cdcffb1848c5946c7c7e6869513f58299384d8f (patch)
tree567562e065775f5709f714ebdd10db22be227bed
parentMerge pull request #2428 from python-discord/dependabot/pip/redis-4.4.2 (diff)
Group thread stats under parent channel (#2440)
Also makes make the stat name slightly more robust to small name changes.
-rw-r--r--bot/exts/info/stats.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/exts/info/stats.py b/bot/exts/info/stats.py
index d4001a7bb..64bff9632 100644
--- a/bot/exts/info/stats.py
+++ b/bot/exts/info/stats.py
@@ -41,12 +41,11 @@ class Stats(Cog):
# of them for interesting statistics to be drawn out of this.
return
- reformatted_name = message.channel.name.replace('-', '_')
-
- if CHANNEL_NAME_OVERRIDES.get(message.channel.id):
- reformatted_name = CHANNEL_NAME_OVERRIDES.get(message.channel.id)
-
- reformatted_name = "".join(char for char in reformatted_name if char in ALLOWED_CHARS)
+ channel = message.channel
+ if hasattr(channel, 'parent'):
+ channel = channel.parent
+ reformatted_name = CHANNEL_NAME_OVERRIDES.get(channel.id, channel.name)
+ reformatted_name = "".join(char if char in ALLOWED_CHARS else '_' for char in reformatted_name)
stat_name = f"channels.{reformatted_name}"
self.bot.stats.incr(stat_name)