@@ -1745,7 +1745,7 @@ async def log_expiry(self):
1745
1745
1746
1746
logger .info (f"Deleted { expired_logs .deleted_count } expired logs." )
1747
1747
1748
- def format_channel_name (self , author , exclude_channel = None , force_null = False ):
1748
+ def format_channel_name (self , author , exclude_channel = None , force_null = False ):
1749
1749
"""Sanitises a username for use with text channel names
1750
1750
1751
1751
Placed in main bot class to be extendable to plugins"""
@@ -1757,7 +1757,7 @@ def format_channel_name(self, author, exclude_channel=None, force_null=False):
1757
1757
if self .config ["use_random_channel_name" ]:
1758
1758
to_hash = self .token .split ("." )[- 1 ] + str (author .id )
1759
1759
digest = hashlib .md5 (to_hash .encode ("utf8" ), usedforsecurity = False )
1760
- name = digest .hexdigest ()[- 8 :]
1760
+ name = digest .hexdigest ()[- 8 :]
1761
1761
elif self .config ["use_user_id_channel_name" ]:
1762
1762
name = str (author .id )
1763
1763
elif self .config ["use_timestamp_channel_name" ]:
@@ -1772,12 +1772,16 @@ def format_channel_name(self, author, exclude_channel=None, force_null=False):
1772
1772
else :
1773
1773
name = author .name .lower ()
1774
1774
1775
- sanitized_name = "" .join (l for l in name if l not in string .punctuation and l .isprintable ()) or "null"
1776
- if author .discriminator != "0" :
1777
- sanitized_name += f"-{ author .discriminator } "
1775
+ sanitized_name = self .sanitize_name (name )
1776
+
1777
+ if author .discriminator != "0" :
1778
+ sanitized_name += f"-{ author .discriminator } "
1778
1779
1779
1780
return ensure_unique_channel_name (sanitized_name , guild , excluse_channel )
1780
1781
1782
+ def sanitize_name (self , name : str ) -> str :
1783
+ return "" .join (l for l in name if l not in string .punctuation and l .isprintable ()) or "null"
1784
+
1781
1785
def ensure_unique_channel_name (self , name , guild , exclude_channel ) -> str :
1782
1786
counter = 1
1783
1787
existed = set (c .name for c in guild .text_channels if c != exclude_channel )
0 commit comments