🐛 fix Event Emitter

This commit is contained in:
Flam3rboy 2021-02-22 08:21:32 +01:00
parent 762b66d50d
commit 5a505f331a
5 changed files with 22 additions and 17 deletions

9
.vscode/launch.json vendored
View File

@ -13,15 +13,6 @@
"preLaunchTask": "tsc: build - tsconfig.json", "preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"] "outFiles": ["${workspaceFolder}/dist/**/*.js"]
}, },
{
"sourceMaps": true,
"type": "node",
"request": "launch",
"name": "Test",
"program": "${workspaceFolder}/dist/test/mongo_test.js",
"preLaunchTask": "tsc: build - tsconfig.json",
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
},
{ {
"name": "Debug current file", "name": "Debug current file",
"program": "${file}", "program": "${file}",

4
package-lock.json generated
View File

@ -1363,7 +1363,7 @@
}, },
"node_modules/fosscord-server-util": { "node_modules/fosscord-server-util": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#57746da87206f31c8612b975df37305fb2a5e0b7", "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#0ab57bb6cd92dbd8c90f716645139d691de7493d",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
@ -5077,7 +5077,7 @@
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
}, },
"fosscord-server-util": { "fosscord-server-util": {
"version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#57746da87206f31c8612b975df37305fb2a5e0b7", "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#0ab57bb6cd92dbd8c90f716645139d691de7493d",
"from": "fosscord-server-util@github:fosscord/fosscord-server-util", "from": "fosscord-server-util@github:fosscord/fosscord-server-util",
"requires": { "requires": {
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",

View File

@ -73,11 +73,11 @@ export class DiscordServer extends Server {
this.app.use(ErrorHandler); this.app.use(ErrorHandler);
const indexHTML = await fs.readFile(__dirname + "/../client_test/index.html"); const indexHTML = await fs.readFile(__dirname + "/../client_test/index.html");
this.app.get("*", (req, res) => { // this.app.get("*", (req, res) => {
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); // res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
res.set("content-type", "text/html"); // res.set("content-type", "text/html");
res.send(indexHTML); // res.send(indexHTML);
}); // });
return super.start(); return super.start();
} }
} }

14
src/routes/test.ts Normal file
View File

@ -0,0 +1,14 @@
import { Router } from "express";
import { getPermission, MemberModel, db } from "fosscord-server-util";
import { Types } from "mongoose";
const router: Router = Router();
router.get("/", async (req, res) => {
// @ts-ignore
const perm = await getPermission(813185668657184768n, 813189959920910336n);
console.log(perm);
if (perm.has("ADD_REACTIONS")) console.log("add");
res.send("OK");
});
export default router;

View File

@ -2,7 +2,7 @@ import { Event, EventModel } from "fosscord-server-util";
export async function emitEvent(payload: Omit<Event, "created_at">) { export async function emitEvent(payload: Omit<Event, "created_at">) {
const emitEvent = { const emitEvent = {
created_at: Math.floor(Date.now() / 1000), // in seconds created_at: new Date(), // in seconds
...payload, ...payload,
}; };