Skip to content

GoruAkiba/socketStats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOCKET STATS | DASHBOARD for DISCORD BOT STATS

Server statistics Dashboard builder for Discord BOT through WebSocket.

dashboard

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://localhost: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:

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 .

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.

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

About

Server statistics Dashboard builder for Discord BOT through WebSocket.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •