#sku

1 messages · Page 1 of 1 (latest)

timid moon

Hello, I have a small issue with an event. I would like an event to occur in a chat room on my server when a user takes a user SKU, but I can't seem to get my code to work. No matter what I do, I get a 404 error.

I already have this:

const skuConfig = {
    "1419256664783327252": { name: "First Hour Supporter", roleId: "1419245835610488984" },
    "1419256794445906040": { name: "Second Hour Supporter", roleId: "1419245846603759688" }
};

async function getOAuthToken(clientId, clientSecret) {
    try {
        const params = new URLSearchParams();
        params.append("grant_type", "client_credentials");
        params.append("scope", "applications.store.update"); // scope requis

        const res = await axios.post(
            "https://discord.com/api/v10/oauth2/token",
            params,
            { auth: { username: clientId, password: clientSecret } }
        );
        return res.data.access_token;
    } catch (err) {
        console.error(":x: Erreur OAuth2:", err.response?.data || err.message);
        return null;
    }
}

async function getSubscriptions(clientId, oauthToken) {
    try {
        const res = await axios.get(
            `https://discord.com/api/v10/applications/${clientId}/subscriptions`,
            { headers: { Authorization: `Bearer ${oauthToken}` } }
        );
        return res.data;
    } catch (err) {
        console.error(":x: Erreur récupération abonnements:", err.response?.data || err.message);
        return [];
    }
}```

I wonder if, apart from webhook endpoints, I could still retrieve and embed a thank you message for user SKU purchases on my server directly in my code?