Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Despite advertising it, this project has no code to get following or followers #59

Open
PixelMelt opened this issue Oct 28, 2024 · 1 comment

Comments

@PixelMelt
Copy link

const following = await soundcloud.users.following("user")

heres what I added

/**
     * Gets a user's followers.
 */
public following = async (userResolvable: string | number, limit?: number) => {
    const userID = await this.resolve.get(userResolvable)
    let response = await this.api.getV2(`/users/${userID}/followings`, {limit: 50, offset: 0}) as any
    const followers: SoundcloudUser[] = []
    let nextHref = response.next_href
    
    while (nextHref && (!limit || followers.length < limit)) {
        followers.push(...response.collection)
        const url = new URL(nextHref)
        const params = {}
        url.searchParams.forEach((value, key) => (params[key] = value))
        response = await this.api.getURL(url.origin + url.pathname, params)
        nextHref = response.next_href
    }
    
    return followers
}
@Moebits
Copy link
Owner

Moebits commented Nov 9, 2024

The readme was for v1 api (now removed).

For code suggestions, I would appreciate if you follow the procedure to open a pull request:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

Also add the followers method for v2 if you can. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants