@mvxxl/sotijs
v1.2.0
Published
Official JavaScript SDK for Soti API
Maintainers
Readme
sotijs
Official JavaScript SDK for Soti API.
Install
npm install sotijsSuper Simple Bot Usage
const { Soti } = require("sotijs");
const { Client, GatewayIntentBits } = require("discord.js");
const bot = new Client({ intents: [GatewayIntentBits.Guilds] });
const soti = new Soti("YOUR_SOTI_API_TOKEN");
const autopost = soti
.autopost()
.initStats(async () => ({
servers: bot.guilds.cache.size,
shards: bot.shard ? bot.shard.count : 1,
members: bot.guilds.cache.reduce((sum, g) => sum + (g.memberCount || 0), 0)
}))
.onSuccess(() => console.log("stats posted"))
.onError((error) => console.error("autopost error", error))
.every("15m");
bot.once("ready", () => {
autopost.start(bot.user.id);
});
bot.login("YOUR_DISCORD_BOT_TOKEN");Constructor
const sotiByToken = new Soti("YOUR_SOTI_API_TOKEN");
const sotiByOptions = new Soti({
siteBaseUrl: "https://flarehub.pro",
apiBaseUrl: "https://api.flarehub.pro",
apiToken: "YOUR_SOTI_API_TOKEN",
botToken: "YOUR_SOTI_BOT_TOKEN"
});Routing defaults:
siteBaseUrl:https://flarehub.proapiBaseUrl:https://api.flarehub.pro- all
"/api/v1/*"go toapiBaseUrl - all other endpoints go to
siteBaseUrl - if
baseUrl: "https://flarehub.pro"is passed,apiBaseUrlis auto-derived ashttps://api.flarehub.pro
Autopost API
autopost().initStats(fn).onSuccess(fn).onError(fn).every(value).start(botId)every(value)supportsms,s,m,hstrings ("30s","15m","1h") or integer millisecondspostNow(botId?)stop()
Client Methods
getApiHealth()getApprovedBots({ category, search })getNewBots()getBot(botId, { strict })getBotStats(botId)getBotStatsHistory(botId, { limit, offset, token, apiToken, botToken })postBotStats(botId, stats)sendBotMetrics(botId, metrics)getSessionInfo()getUserToken()regenerateUserToken()getMyBots()getBotToken(botId)regenerateBotToken(botId)getReviews(botId)submitReview(botId, { rating, reviewText })upvoteBot(botId, { stiospToken, powCounter })getUpvoteCooldown(botId)getUpvoteCount(botId)
Error Types
SotiErrorSotiConnectionErrorSotiValidationErrorSotiAPIError
Publish to npm
npm login
npm publish --access publicLicense
SEE LICENSE IN LICENSE
