Anheledir / Honeycomb

A Discord bot to help artists manage their servers and engage with the community.
https://honeycombs.cloud
MIT License
4 stars 0 forks source link

Add your Patreon profile to your artist profile #32

Open Anheledir opened 1 year ago

Anheledir commented 1 year ago

As artist you can connect your bot profile to your Patreon-Account and also link your patreon tiers to roles on the server.

API-Documentation: https://docs.patreon.com/#user-v2

Sample code:

using System;
using System.Collections.Generic;
using System.Net.Http;
using Newtonsoft.Json;

class Program
{
    static async System.Threading.Tasks.Task Main(string[] args)
    {
        // Replace the placeholders with your actual values
        string campaignId = "your_campaign_id";
        string accessToken = "your_access_token";

        // Define the endpoint URL and headers
        string endpoint = $"https://www.patreon.com/api/oauth2/v2/campaigns/{campaignId}/members";
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

        // Send the API request
        HttpResponseMessage response = await client.GetAsync(endpoint);

        // Parse the response JSON to extract the member data
        string responseContent = await response.Content.ReadAsStringAsync();
        dynamic jsonResponse = JsonConvert.DeserializeObject(responseContent);
        List<dynamic> members = jsonResponse.data.ToObject<List<dynamic>>();

        // Print the member data
        foreach (dynamic member in members)
        {
            decimal pledgeAmount = member.attributes.currently_entitled_amount_cents / 100.0m;
            string discordId = member.attributes.discord_id;
            Console.WriteLine($"Discord ID: {discordId}, Pledge Amount: ${pledgeAmount}");
        }
    }
}
Aralyre commented 1 year ago

AMAZING IDEA!