Skip to content

Commit 59497cc

Browse files
committed
feat: isFollowed auto select mode
1 parent 4a36251 commit 59497cc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/command/user/followed.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,21 @@ export const isFollowed = async (following?: string, follower?: string) => {
2121
const getUser = (username?: string) =>
2222
username ? client.getUser(username) : client.getSelf()
2323

24-
// TODO: auto select mode
24+
const followingUser = getUser(following)
25+
const followerUser = getUser(follower)
26+
27+
const followingProfile = await followingUser.queryProfile()
28+
const followerProfile = await followerUser.queryProfile()
29+
30+
const mode =
31+
followingProfile.user.statsCount.followingCount >
32+
followerProfile.user.statsCount.followedCount
33+
? 'follower'
34+
: 'following'
35+
2536
const isFollowed = await getUser(following).isFollowing(
2637
getUser(follower),
27-
'following'
38+
mode
2839
)
2940

3041
logger.info(isFollowed ? 'Followed!' : 'Not followed.')

0 commit comments

Comments
 (0)