Skip to content

Commit 64a51ed

Browse files
Improve member fetch from ID processing
Signed-off-by: Matt Norton <matt@carrotmanmatt.com>
1 parent 6a40411 commit 64a51ed

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

utils/tex_bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ def _guild_has_channel(self, channel: discord.TextChannel) -> bool:
397397
return bool(discord.utils.get(self.main_guild.text_channels, id=channel.id))
398398

399399
async def _fetch_text_channel(self, name: str) -> discord.TextChannel | None:
400+
name = name.strip()
401+
400402
text_channel: AllChannelTypes | None = discord.utils.get(
401403
await self.main_guild.fetch_channels(),
402404
name=name,
@@ -485,7 +487,7 @@ async def get_member_from_str_id(self, str_member_id: str) -> discord.Member:
485487
Raises `ValueError` if the provided ID does not represent any member
486488
of your group's Discord guild.
487489
"""
488-
str_member_id = str_member_id.replace("<@", "").replace(">", "")
490+
str_member_id = re.sub(r"\A\s*(<@)(.*)(?(1)>|)\s*\Z", r"\2", str_member_id)
489491

490492
if not re.fullmatch(r"\A\d{17,20}\Z", str_member_id):
491493
INVALID_USER_ID_MESSAGE: Final[str] = f"'{str_member_id}' is not a valid user ID."

0 commit comments

Comments
 (0)