async def set_tag(self, conn, new_tag: Optional[str]): if new_tag: # Explicit length error if len(new_tag) > 32: raise errors.TagTooLongError() if contains_custom_emoji(new_tag): raise errors.CustomEmojiError() await db.update_system_field(conn, self.id, "tag", new_tag)
async def set_name(self, conn, new_name: str): """ Set the name of a member. :raises: CustomEmojiError """ # Custom emojis can't go in the member name # Technically they *could*, but they wouldn't render properly # so I'd rather explicitly ban them to in order to avoid confusion if contains_custom_emoji(new_name): raise errors.CustomEmojiError() await db.update_member_field(conn, self.id, "name", new_name)
async def set_tag(self, conn, new_tag: Optional[str]): if new_tag: if len(new_tag) > 32: raise errors.TagTooLongError() if contains_custom_emoji(new_tag): raise errors.CustomEmojiError() members_exceeding = await db.get_members_exceeding(conn, system_id=self.id, length=32 - len(new_tag) - 1) if len(members_exceeding) > 0: raise errors.TagTooLongWithMembersError([member.name for member in members_exceeding]) await db.update_system_field(conn, self.id, "tag", new_tag)