File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -173,11 +173,27 @@ export class JikeUser<M extends boolean = boolean> {
173173 * @param mode
174174 * `following`: 从 当前用户 的 关注 列表查找 目标用户 是否存在;
175175 * `follower` : 从 目标用户 的 被关注 列表查找 当前用户 是否存在。
176+ * `auto` : 根据 `following` 和 `follower` 数量,自动选择上述两种模式。
176177 *
177178 * 为提升查询速度,建议哪个数量少使用哪个。
178179 */
179- async isFollowing ( user : JikeUser | string , mode : 'following' | 'follower' ) {
180+ async isFollowing (
181+ user : JikeUser | string ,
182+ mode : 'following' | 'follower' | 'auto'
183+ ) {
180184 const target = typeof user === 'string' ? this . #client. getUser ( user ) : user
185+
186+ if ( mode === 'auto' ) {
187+ const thisProfile = await this . queryProfile ( )
188+ const targetProfile = await target . queryProfile ( )
189+
190+ mode =
191+ thisProfile . user . statsCount . followingCount >
192+ targetProfile . user . statsCount . followedCount
193+ ? 'follower'
194+ : 'following'
195+ }
196+
181197 const targetUsername = await ( mode === 'following'
182198 ? target . getUsername ( )
183199 : this . getUsername ( ) )
You can’t perform that action at this time.
0 commit comments