Docs/Getting Started/Quick Start

Quick Start

Post stats and check votes in under a minute.

Get up and running with the DiscordForge API in under a minute. This guide assumes you've already installed the package and have an API key.

1. Initialize the Client

index.ts
1import { ForgeClient } from "discordforge-sdk";
2 
3const forge = new ForgeClient(process.env.FORGE_API_KEY, process.env.FORGE_BOT_ID);

2. Post Your Bot Stats

1// Post your bot's server count on startup
2await forge.postStats({
3 serverCount: client.guilds.cache.size,
4 shardCount: client.shard?.count,
5});
6 
7console.log("Stats posted successfully!");

3. Check If a User Voted

1const vote = await forge.checkVote("USER_DISCORD_ID");
2 
3if (vote.hasVoted) {
4 console.log(`User voted at ${vote.votedAt}`);
5 console.log(`Next vote available at ${vote.nextVoteAt}`);
6} else {
7 console.log("User has not voted in the last 8 hours");
8}

4. Get Bot Info

1// No auth required for this endpoint
2const bot = await forge.getBot();
3 
4console.log(bot.name);
5console.log(`${bot.voteCount} votes`);
6console.log(`${bot.serverCount} servers`);

That's it! Check the API Reference for detailed documentation on each endpoint.