GitHub Sponsors Integration

Comments

8 comments

  • ivangodinez21

    I like this idea, like Twitch, give access to the developer server if they are sponsoring us in GitHub with GitHub Sponsors.

    Something like this interface:

    • For GitHub user (Developer)

    • For GitHub Sponsor (Donator)

    1
  • midudev

    I'm here just to support this! :)

    0
  • April

    I'd also love to see this. I believe it should be possible to replicate via a Discord bot to utilise GitHub Sponsor webhooks, but no such thing seems to exist and I don't have the free time to try my own hand at it.

    0
  • Hauleth

    It seems that Sponsors web hooks now exists, so the only missing link is to be able to automatically assign group.

    0
  • BogDrakonov

    This would be absolutely amazing and a perk I'd love to offer!

    0
  • balupton

    I'll be doing a bunch of stuff with GitHub sponsors in the coming months, and planning to use Discord for my community. If anyone wants to fund this development, I can commit to it on my infinite todo list. Reach out at b@lupton.cc

    0
  • Jon

    I've spent a good while researching how one might do this, and keep running into things that make this complicated. Wouldn't be too hard to fix “from the inside” at Discord, but as an external dev making the experience nice with a bot will be tricky:

    - [Linked Roles](https://discord.com/developers/docs/tutorials/configuring-app-metadata-for-linked-roles) can't be used because the connections metadata is global, not per-server. So such an integration would need to make a key for every project a user sponsors where the value is how much they sponsor by, which would almost certainly bother privacy-concerned users.

    - Discord bots [cannot create managed roles](https://stackoverflow.com/questions/74951995/create-a-managed-role-in-discord), so such a bot would need to create roles that may then also (perhaps accidentally) be modified by the server admins, potentially leading to desynchronization.

    - Discord bots [cannot access connections info](https://support.discord.com/hc/en-us/community/posts/360032816691-Allow-bot-users-to-access-connected-user-accounts-of-guild-members), meaning the bot would have to make users go through a GitHub OAuth flow to get their GitHub information even if they have already linked their Discord to their GitHub.

    - GitHub Apps [can't access sponsorships](https://github.com/orgs/community/discussions/44226), meaning a GitHub OAuth App is needed, even though GitHub [discourages their use](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps).

    - There isn't, as far as I can tell, a convenient way for a Discord bot to take an action when it is installed into a new server. In this case, to tell the server admin to go through the GitHub OAuth flow to grant the bot read access to their GitHub sponsors. The Gateway API _may_ allow this (via [`Ready`](https://discord.com/developers/docs/topics/gateway-events#ready) and `GuildCreated` events), but is very much overkill for the simple integration we need here, and would also require the bot to set up a persistent connection (precluding easy use of cheap execution options like AWS Lambda).

     

    Some other notes if someone decides to take this on regardless:

    - You'll probably want to handle webhooks both for GitHub Sponsors (for when a user becomes a sponsor, changes their tier, or stops sponsoring). Webhook URLs have to be set _manually_ (as far as I can tell) in the settings panel by each user. And that means the webhook secret will also need to be manually communicated back to the bot.

    - You'll almost certainly want to use [Global Node IDs](https://docs.github.com/en/graphql/guides/using-global-node-ids) to identify GitHub users rather than (just) usernames. Make sure you use the [new format](https://docs.github.com/en/graphql/guides/migrating-graphql-global-node-ids) from the very beginning.

    - You'll probably also want to handle webhooks for Discord, specifically join/leave events on each associated server, to see if someone joins that is also linked to a GitHub user who is a sponsor.

    - The bot should not require a user to link their GitHub once for each Discord server. Instead, ideally, a user should be able to link their GitHub with the bot once, and then that should take effect for _any_ server that also uses the same bot.

    - GitHub Sponsor tiers don't have names. As a result, you'll probably want to auto-generate roles whose name is just the price per month of the tier, and then leave it up to the server admin to rename the role.

    - On GitHub Sponsors, users can choose to do one-time sponsorships and custom amounts. You'll need to exclude the former from granting roles, and you'll probably want to make the latter such that a user is granted the highest-cost tier that is at-or-below the custom amount. Make sure to also handle these correctly when you get a sponsorship tier _change_ event from the GitHub webhook.

    0
  • endel

    Would love to see this happening, too!

    0

Please sign in to leave a comment.