Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fc5570/danbot-hosting-stats-poster
A stats poster for danbot-hosting bot API.
https://github.com/fc5570/danbot-hosting-stats-poster
danbot danbot-hosting discord js
Last synced: about 2 months ago
JSON representation
A stats poster for danbot-hosting bot API.
- Host: GitHub
- URL: https://github.com/fc5570/danbot-hosting-stats-poster
- Owner: FC5570
- Created: 2021-08-25T17:10:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-26T01:54:27.000Z (over 2 years ago)
- Last Synced: 2024-08-09T04:59:18.362Z (5 months ago)
- Topics: danbot, danbot-hosting, discord, js
- Language: JavaScript
- Homepage: https://npmjs.com/package/danbot-hosting-stats-poster
- Size: 8.79 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# danbot-hosting-stats-poster
Posts stats to [Danbot Hosting's](https://danbot.host) bot API.
## Installation
NPM:
```
npm i danbot-hosting-stats-poster
```Yarn:
```
yarn add danbot-hosting-stats-poster
```## Setting Up
1. To start with posting stats, go to #bot-commands in the [Discord Server](https://discord.com/invite/dbh) and type `DBH!apikey`, the bot will send you your API key.
2. Use the API key in the examples provided below.
3. Call the `autoPost()` function after you've instantiated a new AutoPoster client.
4. If everything went fine, your bot's stats will be posted to the API, and your bot will be added to the server if you want.## Examples
```js
const { Client } = require("discord.js");
const AutoPoster = require("danbot-hosting-stats-poster");
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });const poster = new AutoPoster(client, {
key: "danbot-apikey", //replace this with your api key
});client.on("ready", async () => {
console.log("logged in");
await poster.autoPost();
});poster.on("autoPostingStarted", (post) => {
console.log(`Auto posting has started - ${post.statusText}`);
});poster.on("post", (post) => {
console.log(`Posted to the API - ${post.status}`);
});poster.on("error", (code, text, response) => {
console.log(`An error occured while posting -`, code, text, response);
});client.login("your token");
```## Events
1. `autoPostingStarted` _(post)_ - Emitted when the AutoPoster starts posting to the API.
2. `posted` _(post)_ - Emitted when the AutoPoster posts to the API everytime.
3. `error` _(code, message, response)_ - Emitted when an error is occured while making a request to the API.## API
### AutoPoster.constructor(client, AutoPosterOptions)
`AutoPosterOptions` is an object which can contain the following:
1. **key** _(string)_ - The API key which you get from the bot (if you don't know where to get the API key, [read this](https://npmjs.com/danbot-hosting-stats-poster#settingup))
2. **guildCount** _(string, optional)_ - The guild count of the bot.
3. **userCount** _(string, optional)_ - The user count of the bot.
4. **postInterval** _(string, optional)_ - The interval (in milliseconds) to make posts at.### AutoPoster.autoPost()
This will start posting stats to the API and emit the `autoPostingStarted` and `posted` events.
### If you encounter any bugs/issues, please DM me on Discord: FC#5104