diff options
Diffstat (limited to 'src/server.ts')
| -rw-r--r-- | src/server.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..b216ff4 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,35 @@ +import express from 'express'; +import bodyParser from 'body-parser'; + +class WebSocket { + constructor(port, client) { + 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.get('/', (req, res) => { + res.redirect('https://kyzer.co/discord/bots/uwufier/') + }) + this.app.get('/api/v1/commands/', async (req, res) => { + res.json({ guilds: await this.client.registry.commands.size }) + }); + this.app.get('/api/v1/commands/groups/', async (req, res) => { + res.json({ guilds: await this.client.registry.groups.size }) + }); + this.app.get('/api/v1/servers/', async (req, res) => { + res.json({ guilds: await this.client.guilds.cache.size }) + }); + } +} + +module.exports = WebSocket
\ No newline at end of file |