//@ts-nocheck //TODO: this import express from 'express'; import bodyParser from 'body-parser'; class WebSocket { client: any; app: any; server: any; constructor(port: any, client: any) { this.client = client; this.app = express() this.app.use(bodyParser.urlencoded({ extended: false })) this.app.use(bodyParser.json()) this.registerRoots() this.server = this.app.listen(port, () => { console.log('\x1b[0m' + 'Listening on port: ' + '\x1b[36m' + this.server.address().port) }) } // http://localhost:port?token=123456 registerRoots() { this.app.all('*', function (req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type'); next(); }); this.app.get('/', (req, res) => { res.redirect('https://kyzer.co/discord/bots/uwufier/') }) this.app.get('/api/v1/commands/', async (req, res) => { res.json({ commands: await this.client.registry.commands.size }) }); this.app.get('/api/v1/groups/', async (req, res) => { res.json({ groups: await this.client.registry.groups.size }) }); this.app.get('/api/v1/commands/groups/', async (req, res) => { res.json({ groups: await this.client.registry.groups.size }) }); this.app.get('/api/v1/guilds/', async (req, res) => { res.json({ guilds: await this.client.guilds.cache.size }) }); } } module.exports = WebSocket