# socketstats

> Server statistics Dashboard builder for Discord BOT through WebSocket.

Latest version **1.0.9** (published 2020-08-26) · GNU GPLv3 license · 0 weekly downloads

## Install

```sh
npm install socketstats
pnpm add socketstats
yarn add socketstats
bun add socketstats
```

Provides the command `socketstats`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2020-08-26 |
| First published | 2020-08-22 |
| Weekly downloads | 0 |
| License | GNU GPLv3 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 55.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | goruakiba |
| Maintainers | goruakiba |
| Keywords | Discord.js, Dashboard-Stats, socket.io |

## Links

- npm: https://www.npmjs.com/package/socketstats
- Repository: https://github.com/GoruAkiba/socketStats
- Homepage: https://github.com/GoruAkiba/socketStats#readme.md
- Issues: https://github.com/GoruAkiba/socketStats/issues
- npm.io page: https://npm.io/package/socketstats

## Dependencies (3)

- [express](https://npm.io/package/express.md) ^4.17.1
- [os-utils](https://npm.io/package/os-utils.md) 0.0.14
- [socket.io](https://npm.io/package/socket.io.md) ^2.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2020-08-26
- 1.0.8 — 2020-08-22
- 1.0.7 — 2020-08-22
- 1.0.6 — 2020-08-22
- 1.0.5 — 2020-08-22

## README

SOCKET STATS | DASHBOARD for DISCORD BOT STATS
============================================== 
> Server statistics Dashboard builder for Discord BOT through WebSocket.
<center>

![dashboard](https://cdn.discordapp.com/attachments/664516457542975492/746637803332304966/unknown.png)

</center>
This dasboard base on Bootstrap and chart.js. then for the comunication we open a websocket using socket.io

installing this package and complete all requirement, ur project will automatically make websocket server and open new routing following `http://localost:8080/gb-status`. or `<project_url>/gb-status`


> The following example attaches project to a plain Node.JS HTTP server listening on port 8080 .



## Requirement
this project require following packages:
+ [express](https://www.npmjs.com/package/express)
+ [socket.io](https://www.npmjs.com/package/socket.io)
+ [os-utils](https://www.npmjs.com/package/os-utils)

## Installation
install the package using:
```
$ npm install socketstats
```

### Basic routing
then use express and create express basic routing.
> The following example attaches project to a plain Node.JS HTTP server listening on port 8080 .
```js
const express = require("express");
const app = express();
const _PORT = process.env.PORT || 8080;

// routing
//.....
//.....
// routing end

// common case listening port given by express
app.listen(_PORT, () => {
    console.log("Listening to port: "+_PORT);
})

```

to make `WebServer` and `WebSocket` **run in singgle server**. You need to pass the `Server` to `socketstats`, and not the express application function. Also make sure to call `.listen` on the `server`, not the `app`.

then for gathering info from the bot we need authorize `client` fom discord. so we do listen to port after te bot is ready.
```js
const express = require("express");
const app = express();
const _PORT = process.env.PORT || 8080;

// routing
//.....
//.....
// routing end

// common case listening port given by express
// app.listen(_PORT, () => {
//     console.log("Listening to port: "+_PORT);
// })

// basic discord,js BOT requirement
const Discord = require("discord.js");
const client = Discord.Client();

// some handler command
// .....
// .....

client.on('ready', () => {
    console.log('Ready..!')

    // socketStats Configuration
    const socketStats = require("socketstats");
    const server = new socketStats(app, client);

    // open / listen port using socketStats
    server.listen(_PORT, () => {
        console.log("Listening to port: "+_PORT);
    });

});

// basic discord.js BOT login method
client.login(Token)


```

## License

[GNU GPLv3](https://github.com/GoruAkiba/socketStats/blob/master/LICENSE)

---
_Source: https://npm.io/package/socketstats · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
