bump4you.js
v1.0.23
Published
An API wrapper for the Bump4You API
Readme
About
bump4you.js provides developers with an intuitive interface to interact with the Bump4You API. Built with TypeScript, we provide full typings and a unified Client structure
that feels right at home for developers familiar with discord.js.
Quick Start
npm install bump4you.jsInitializing the Client
import { Client } from "bump4you.js";
const client = new Client({
baseURL: "https://api.bump4you.com", // Base API URL
version: "v1", // API Version
apiKey: "YOUR_API_KEY", // Your x-api-key
});To get an API key, you will need to join our support server and contact a staff member.
Basic Usage
Below is a quick glance at all the available functions under the guilds and users managers.
Guilds Manager (client.guilds)
// Fetch a guild's profile
const guild = await client.guilds.fetch("GUILD_ID");
// Create a new guild
const newGuild = await client.guilds.create("GUILD_ID", {
/* CreateGuildDto */
});
// Overwrite a guild using new data
const replacedGuild = await client.guilds.replace("GUILD_ID", {
/* CreateGuildDto */
});
// Update specific fields on a guild
const updatedGuild = await client.guilds.edit("GUILD_ID", {
/* UpdateGuildDto */
});
// Mark a guild as deleted
const deletedGuild = await client.guilds.delete("GUILD_ID");
// Restore a previously deleted guild
const restoredGuild = await client.guilds.restore("GUILD_ID");
// --- Administrative Methods ---
await client.guilds.setChecked("GUILD_ID", true);
await client.guilds.setForceNSFW("GUILD_ID", true);
await client.guilds.setShadowBanned("GUILD_ID", true);
await client.guilds.setBanned("GUILD_ID", true);
await client.guilds.setPartnered("GUILD_ID", true);
await client.guilds.setPremium("GUILD_ID", true);
// --- Operations ---
// Bump a guild
const result = await client.guilds.bump("GUILD_ID", {
/* BumpDto */
});
// Fetch a guild's statistics
const stats = await client.guilds.getStats("GUILD_ID");
// --- Reports ---
const report = await client.guilds.getReport("GUILD_ID", "REPORT_ID");
const newReport = await client.guilds.createReport("GUILD_ID", {
/* CreateReportDto */
});
await client.guilds.deleteReport("GUILD_ID", "REPORT_ID");Users Manager (client.users)
// Fetch a user's profile
const user = await client.users.fetch("USER_ID");
// Create a new user profile
const newUser = await client.users.create("USER_ID", {
/* CreateUserDto */
});
// Overwrite a user's profile
const replacedUser = await client.users.replace("USER_ID", {
/* CreateUserDto */
});
// Update specific fields on a user's profile
const updatedUser = await client.users.edit("USER_ID");
// Delete a user's profile
const deletedUser = await client.users.delete("USER_ID");Error Handling
If an API request fails, bump4you.js will throw a custom Bump4YouAPIError. This error includes the HTTP status code, letting you easily differentiate between errors such as
hitting a cooldown (429) vs a not found (404).
import { Bump4YouAPIError } from "bump4you.js";
try {
const result = await client.guilds.bump("GUILD_ID", {
/* BumpDto */
});
} catch (error) {
if (error instanceof Bump4YouAPIError) {
if (error.code === 404) {
console.error("Guild not found in the database!");
} else if (error.code === 429) {
console.error("Guild is on cooldown! Try again later.");
} else {
console.error(`API Error ${error.code}: ${error.message}`);
}
} else {
console.error("An unexpected error occurred:", error);
}
}Need Help?
Join our Discord Support Server if you have any questions or need assistance integrating the Bump4You API!
