summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author8cy <[email protected]>2020-05-05 17:20:56 -0700
committer8cy <[email protected]>2020-05-05 17:20:56 -0700
commita9736fde2706e37aac691184e78f7686e1dd76aa (patch)
tree941e121d9df6bf56e0bef3e9f887cbc56a843946
parentupdate dependencies (diff)
downloaddep-core-a9736fde2706e37aac691184e78f7686e1dd76aa.tar.xz
dep-core-a9736fde2706e37aac691184e78f7686e1dd76aa.zip
add api, change sementic version tag
because of adding an api, a change was need to Procfile, making it a web process in heroku i also removed unused dependencies from the webserver file and made responses into json objects dont worry, i am using uptime robot ;) - renamed ws to server -changed sementic version from v10.0.0 to v1.10.0, minecraft versions :D
-rw-r--r--Procfile2
-rw-r--r--package.json2
-rw-r--r--spike/ws/css/main.css (renamed from spike/ws/public/css/main.css)0
-rw-r--r--spike/ws/layouts/layout.hbs20
-rw-r--r--spike/ws/views/error.hbs1
-rw-r--r--spike/ws/views/index.hbs2
-rw-r--r--spike/ws/ws.ts54
-rw-r--r--src/bot.ts4
-rw-r--r--src/config.json2
-rw-r--r--src/server.ts35
10 files changed, 42 insertions, 80 deletions
diff --git a/Procfile b/Procfile
index 3ac3b3b..c581b3e 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-worker: node ./dist/app.js
+web: node ./dist/app.js
diff --git a/package.json b/package.json
index 3ea132c..8ab3a99 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "uwufier",
- "version": "9.3.2",
+ "version": "1.10.0",
"description": "A Discord bot that supports audio playback, fun commands, utilities, and soundsboard, and more to come!",
"main": "./dist/app.js",
"scripts": {
diff --git a/spike/ws/public/css/main.css b/spike/ws/css/main.css
index 993c46a..993c46a 100644
--- a/spike/ws/public/css/main.css
+++ b/spike/ws/css/main.css
diff --git a/spike/ws/layouts/layout.hbs b/spike/ws/layouts/layout.hbs
index 844e9da..7d0785a 100644
--- a/spike/ws/layouts/layout.hbs
+++ b/spike/ws/layouts/layout.hbs
@@ -1,19 +1 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>{{title}}</title>
- <link rel="stylesheet" href="css/main.css">
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
- </head>
- <body>
- <div title="Status: Online">
- {{body}}
- </div>
-
- <div class="footer">
- <p>Copyright &COPY; 2020 - <a href="https://cyne.cf">s1nical</a></p>
- </div>
- </body>
-</html> \ No newline at end of file
+{{body}} \ No newline at end of file
diff --git a/spike/ws/views/error.hbs b/spike/ws/views/error.hbs
deleted file mode 100644
index fe49573..0000000
--- a/spike/ws/views/error.hbs
+++ /dev/null
@@ -1 +0,0 @@
-Error: {{errtype}} \ No newline at end of file
diff --git a/spike/ws/views/index.hbs b/spike/ws/views/index.hbs
index 5253033..b815c9b 100644
--- a/spike/ws/views/index.hbs
+++ b/spike/ws/views/index.hbs
@@ -1 +1 @@
-Status: Online \ No newline at end of file
+{{response}} \ No newline at end of file
diff --git a/spike/ws/ws.ts b/spike/ws/ws.ts
deleted file mode 100644
index 08f9581..0000000
--- a/spike/ws/ws.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import express from 'express';
-import hbs from 'express-handlebars';
-import bodyParser from 'body-parser';
-import path from 'path';
-
-class WebSocket {
- constructor(token, port, client) {
- this.token = token;
- this.client = client;
-
- this.app = express()
- this.app.engine('hbs', hbs({
- extname: 'hbs',
- defaultLayout: 'layout',
- layoutsDir: __dirname + '/layouts'
- }))
- this.app.set('views', path.join(__dirname, 'views'))
- this.app.set('view engine', 'hbs')
- this.app.use(express.static(path.join(__dirname, 'public')))
- this.app.use(bodyParser.urlencoded({ extended: false }))
- this.app.use(bodyParser.json())
-
- this.registerRoots()
-
- this.server = this.app.listen(port, () => {
- console.log(`Websocket listening on port ${this.server.address().port}`)
- })
- }
-
- checkToken(_token) {
- return (_token == this.token)
- }
-
- // http://localhost:port?token=123456
- registerRoots() {
- this.app.get('/', (req, res) => {
- var _token = req.query.token
- // if (!this.checkToken(_token)) {
- // res.render('error', {
- // title: 's1nical - Error',
- // errtype: 'INVALID TOKEN'
- // })
- // return
- // }
-
- res.render('index', {
- title: 'Uwufier - Status',
- token: _token
- })
- })
- }
-}
-
-module.exports = WebSocket \ No newline at end of file
diff --git a/src/bot.ts b/src/bot.ts
index 337a772..8334cc8 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -1,6 +1,6 @@
import config from './config.json';
import { CommandoClient } from 'discord.js-commando';
-//import WS from './ws/ws';
+import WS from './server';
import Welcome from './models/welcome.js';
import Goodbye from './models/goodbye.js';
import mongoose from 'mongoose';
@@ -16,7 +16,7 @@ const client = new CommandoClient({
invite: 'https://discord.gg/DVwXUwx'
});
-//var ws = new WS('123456', process.env.PORT, client)
+const ws = new WS(process.env.PORT, client)
client.registry
.registerDefaultTypes()
diff --git a/src/config.json b/src/config.json
index 8dc7da6..9cdd651 100644
--- a/src/config.json
+++ b/src/config.json
@@ -1,7 +1,7 @@
{
"secret":"Njk5NDczMjYzOTk4MjcxNDg5.XpU5oQ.btZuxVudhNllSQY6CxrXXtMJm9A",
"yt-api-key":"AIzaSyCeG1lQAeInv4vjFv_eTL9IFAFNdQC9Nk8",
- "version":"9.3.2",
+ "version":"1.10.0",
"fortniteTrackerNetworkToken": "4cf21f95-5f1a-412a-b4a7-e5424adc314a",
"maxMultipler": 100,
"minMultipler": 1.01
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