mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-25 22:54:51 +00:00
Cleanup, reformat, fix some todos, git hook
fixup! Cleanup, reformat, fix some todos, git hook
This commit is contained in:
@@ -13,11 +13,11 @@ jobs:
|
||||
os: [windows, macos, ubuntu]
|
||||
include:
|
||||
- os: windows
|
||||
deps: ''
|
||||
deps: ""
|
||||
- os: macos
|
||||
deps: ''
|
||||
deps: ""
|
||||
- os: ubuntu
|
||||
deps: 'sudo apt install -y libpango1.0-dev libgif-dev'
|
||||
deps: "sudo apt install -y libpango1.0-dev libgif-dev"
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
Vendored
+4
-2
@@ -7,7 +7,9 @@
|
||||
"name": "Launch Program",
|
||||
"skipFiles": ["<node_internals>/**"],
|
||||
"program": "${file}",
|
||||
"outFiles": ["${workspaceFolder}/**/*.js"]
|
||||
"outFiles": ["${workspaceFolder}/**/*.js"],
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
],
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compiler": "tsc",
|
||||
"verbose": true,
|
||||
"writeBuildLog": true,
|
||||
"writeAnsiBuildLog": true,
|
||||
"logErrors": true,
|
||||
"tsc": {
|
||||
"prettyErrors": true
|
||||
},
|
||||
"clean": true,
|
||||
"quiet": false,
|
||||
"steps": {
|
||||
"pre": ["clean", "plugin_prepare"],
|
||||
"post": ["plugin_resources", "remap_imports"]
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@
|
||||
"@types/ws": "^8.5.3",
|
||||
"jest": "^28.1.3",
|
||||
"jest-expect-message": "^1.0.2",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-organize-imports": "^3.0.3",
|
||||
"supertest": "^6.1.6",
|
||||
"ts-node": "^10.2.1",
|
||||
@@ -85,6 +86,7 @@
|
||||
"multer": "^1.4.5-lts.1",
|
||||
"node-2fa": "^2.0.3",
|
||||
"node-fetch": "^2.6.7",
|
||||
"node-git-hooks": "^1.0.6",
|
||||
"patch-package": "^6.4.7",
|
||||
"picocolors": "^1.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
|
||||
+5
-5
@@ -29,7 +29,7 @@ if (silent) console.error = console.log = function () {};
|
||||
|
||||
if (argv.includes("clean")) {
|
||||
console.log(`[${++i}/${steps}] Cleaning...`);
|
||||
let d = "dist";
|
||||
let d = "../" + "/dist";
|
||||
if (fs.existsSync(d)) {
|
||||
fs.rmSync(d, { recursive: true });
|
||||
if (verbose) console.log(`Deleted ${d}!`);
|
||||
@@ -110,7 +110,7 @@ if (!argv.includes("copyonly")) {
|
||||
}
|
||||
|
||||
console.log(`[${++i}/${steps}] Copying plugin data...`);
|
||||
let pluginFiles = walk(pluginDir).filter((x) => !x.endsWith(".ts"));
|
||||
pluginFiles.forEach((x) => {
|
||||
fs.copyFileSync(x, x.replace("src", "dist"));
|
||||
});
|
||||
let pluginFiles = walk(pluginDir).filter(x=>!x.endsWith('.ts'));
|
||||
pluginFiles.forEach(x=>{
|
||||
fs.copyFileSync(x, x.replace('src','dist'))
|
||||
})
|
||||
@@ -5,6 +5,8 @@ const { execSync } = require("child_process");
|
||||
const { argv, stdout, exit } = require("process");
|
||||
const { execIn, getLines } = require("./utils");
|
||||
|
||||
const { execIn, getLines } = require("./utils");
|
||||
|
||||
const bundleRequired = ["@ovos-media/ts-transform-paths"];
|
||||
const removeModules = argv.includes("cleanup");
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ let lines3 = lines2.filter((y) => y.includes(": BitFlag("));
|
||||
let lines4 = lines3.map((x) => x.split("//")[0].trim());
|
||||
|
||||
function BitFlag(int) {
|
||||
return 1n << BigInt(int);
|
||||
return 1n << eval(`${int}n`);
|
||||
}
|
||||
|
||||
let rights = [];
|
||||
|
||||
+10
-10
@@ -8,7 +8,10 @@ import { Config, getOrInitialiseDatabase } from "@fosscord/util";
|
||||
import * as Sentry from "@sentry/node";
|
||||
import * as Tracing from "@sentry/tracing";
|
||||
import { PluginLoader } from "@fosscord/util";
|
||||
import { PluginConfig } from "util/plugin/PluginConfig";
|
||||
import express from "express";
|
||||
import http from "http";
|
||||
import { bold, green, yellow } from "picocolors";
|
||||
import { PluginConfig } from "./util/plugin/PluginConfig";
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer();
|
||||
@@ -16,11 +19,8 @@ const port = Number(process.env.PORT) || 3001;
|
||||
const production = process.env.NODE_ENV == "development" ? false : true;
|
||||
server.on("request", app);
|
||||
|
||||
// @ts-ignore
|
||||
const api = new Api.FosscordServer({ server, port, production, app });
|
||||
// @ts-ignore
|
||||
const cdn = new CDNServer({ server, port, production, app });
|
||||
// @ts-ignore
|
||||
const gateway = new Gateway.Server({ server, port, production });
|
||||
|
||||
//this is what has been added for the /stop API route
|
||||
@@ -38,13 +38,13 @@ async function main() {
|
||||
await PluginConfig.init();
|
||||
|
||||
//Sentry
|
||||
if (Config.get().sentry.enabled) {
|
||||
if (cfg.sentry.enabled) {
|
||||
console.log(`[Bundle] ${yellow("You are using Sentry! This may slightly impact performance on large loads!")}`);
|
||||
Sentry.init({
|
||||
dsn: Config.get().sentry.endpoint,
|
||||
dsn: cfg.sentry.endpoint,
|
||||
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
|
||||
tracesSampleRate: Config.get().sentry.traceSampleRate,
|
||||
environment: Config.get().sentry.environment
|
||||
tracesSampleRate: cfg.sentry.traceSampleRate,
|
||||
environment: cfg.sentry.environment
|
||||
});
|
||||
|
||||
app.use(Sentry.Handlers.requestHandler());
|
||||
@@ -54,7 +54,7 @@ async function main() {
|
||||
server.listen(port);
|
||||
await Promise.all([api.start(), cdn.start(), gateway.start()]);
|
||||
|
||||
if (Config.get().sentry.enabled) {
|
||||
if (cfg.sentry.enabled) {
|
||||
app.use(Sentry.Handlers.errorHandler());
|
||||
app.use(function onError(err: any, req: any, res: any, next: any) {
|
||||
res.statusCode = 500;
|
||||
@@ -63,7 +63,7 @@ async function main() {
|
||||
}
|
||||
|
||||
console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`);
|
||||
await PluginLoader.loadPlugins();
|
||||
PluginLoader.loadPlugins();
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import { Server, ServerOptions } from "lambert-server";
|
||||
import morgan from "morgan";
|
||||
import path from "path";
|
||||
import { red } from "picocolors";
|
||||
import { PluginConfig } from "../util";
|
||||
import { Authentication, CORS } from "./middlewares/";
|
||||
import { BodyParser } from "./middlewares/BodyParser";
|
||||
import { ErrorHandler } from "./middlewares/ErrorHandler";
|
||||
@@ -40,7 +41,7 @@ export class FosscordServer extends Server {
|
||||
await initEvent();
|
||||
await initInstance();
|
||||
|
||||
let logRequests = process.env["LOG_REQUESTS"] != undefined;
|
||||
let logRequests = "LOG_REQUESTS" in process.env;
|
||||
if (logRequests) {
|
||||
this.app.use(
|
||||
morgan("combined", {
|
||||
|
||||
@@ -9,14 +9,13 @@ export function ErrorHandler(error: Error, req: Request, res: Response, next: Ne
|
||||
let code = 400;
|
||||
let httpcode = code;
|
||||
let message = error?.toString();
|
||||
let errors = undefined;
|
||||
let data = undefined;
|
||||
let errors = null;
|
||||
let data = null;
|
||||
|
||||
if (error instanceof HTTPError && error.code) {
|
||||
code = httpcode = error.code;
|
||||
if(error.data) data = error.data;
|
||||
}
|
||||
else if (error instanceof ApiError) {
|
||||
if (error.data) data = error.data;
|
||||
} else if (error instanceof ApiError) {
|
||||
code = error.code;
|
||||
message = error.message;
|
||||
httpcode = error.httpStatus;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getIpAdress } from "@fosscord/api";
|
||||
import { Config, getRights, listenEvent } from "@fosscord/util";
|
||||
import { NextFunction, Request, Response, Router } from "express";
|
||||
import { getIpAdress } from "..";
|
||||
import { API_PREFIX_TRAILING_SLASH } from "./Authentication";
|
||||
|
||||
// Docs: https://discord.com/developers/docs/topics/rate-limits
|
||||
|
||||
@@ -10,6 +10,7 @@ import { patchFile } from "..";
|
||||
|
||||
const prettier = require("prettier");
|
||||
const AssetsPath = path.join(__dirname, "..", "..", "..", "assets");
|
||||
const cfg = Config.get();
|
||||
|
||||
export default function TestClient(app: Application) {
|
||||
const agent = new ProxyAgent();
|
||||
@@ -81,22 +82,22 @@ export default function TestClient(app: Application) {
|
||||
return res.send(fs.readFileSync(assetCacheItem.FilePath));
|
||||
});
|
||||
app.get("/developers*", (_req: Request, res: Response) => {
|
||||
const { useTestClient } = Config.get().client;
|
||||
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
|
||||
res.set("content-type", "text/html");
|
||||
|
||||
if (!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
|
||||
if (!cfg.client.useTestClient)
|
||||
return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
|
||||
|
||||
res.send(fs.readFileSync(path.join(__dirname, "..", "..", "..", "assets", "developers.html"), { encoding: "utf8" }));
|
||||
});
|
||||
app.get("*", (req: Request, res: Response) => {
|
||||
const { useTestClient } = Config.get().client;
|
||||
res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24);
|
||||
res.set("content-type", "text/html");
|
||||
|
||||
if (req.url.startsWith("/api") || req.url.startsWith("/__development")) return;
|
||||
|
||||
if (!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
|
||||
if (!cfg.client.useTestClient)
|
||||
return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.");
|
||||
if (req.url.startsWith("/invite")) return res.send(html.replace("9b2b7f0632acd0c5e781", "9f24f709a3de09b67c49"));
|
||||
|
||||
res.send(html);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
//const { exclude_consumed } = req.query;
|
||||
res.status(200).send([]);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Router } from "express";
|
||||
const router: Router = Router();
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
|
||||
export default router;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({ permission: "MANAGE_MESSAGES" }), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json({
|
||||
id: "",
|
||||
type: 0,
|
||||
|
||||
@@ -12,12 +12,10 @@ import {
|
||||
Message,
|
||||
MessageCreateEvent,
|
||||
MessageCreateSchema,
|
||||
Snowflake,
|
||||
uploadFile,
|
||||
Member,
|
||||
MessageCreateSchema,
|
||||
PluginEventHandler,
|
||||
PreMessageEventArgs
|
||||
PreMessageEventArgs,
|
||||
Snowflake,
|
||||
uploadFile
|
||||
} from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import multer from "multer";
|
||||
@@ -210,8 +208,8 @@ router.post(
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
//Defining member fields
|
||||
|
||||
//Defining member fields
|
||||
var member = await Member.findOneOrFail({ where: { id: req.user_id }, relations: ["roles", "user"] });
|
||||
// TODO: This doesn't work either
|
||||
// member.roles = member.roles.filter((role) => {
|
||||
@@ -224,10 +222,17 @@ router.post(
|
||||
// delete message.member.last_message_id;
|
||||
// delete message.member.index;
|
||||
|
||||
let blocks = (await PluginEventHandler.preMessageEvent({
|
||||
message
|
||||
} as PreMessageEventArgs)).filter(x=>x.cancel);
|
||||
if(blocks.length > 0) throw new HTTPError("Message denied.", 400, blocks.filter(x=>x.blockReason).map(x=>x.blockReason));
|
||||
let blocks = (
|
||||
await PluginEventHandler.preMessageEvent({
|
||||
message
|
||||
} as PreMessageEventArgs)
|
||||
).filter((x) => x.cancel);
|
||||
if (blocks.length > 0)
|
||||
throw new HTTPError(
|
||||
"Message denied.",
|
||||
400,
|
||||
blocks.filter((x) => x.blockReason).map((x) => x.blockReason)
|
||||
);
|
||||
|
||||
await Promise.all([
|
||||
message.save(),
|
||||
|
||||
@@ -26,7 +26,7 @@ router.put("/:user_id", route({}), async (req: Request, res: Response) => {
|
||||
return res.status(201).json(new_channel);
|
||||
} else {
|
||||
if (channel.recipients!.map((r) => r.user_id).includes(user_id)) {
|
||||
throw DiscordApiErrors.INVALID_RECIPIENT; //TODO is this the right error?
|
||||
throw DiscordApiErrors.INVALID_RECIPIENT; //TODO: is this the right error?
|
||||
}
|
||||
|
||||
channel.recipients!.push(OrmUtils.mergeDeep(new Recipient(), { channel_id, user_id: user_id }));
|
||||
@@ -57,7 +57,7 @@ router.delete("/:user_id", route({}), async (req: Request, res: Response) => {
|
||||
throw DiscordApiErrors.MISSING_PERMISSIONS;
|
||||
|
||||
if (!channel.recipients!.map((r) => r.user_id).includes(user_id)) {
|
||||
throw DiscordApiErrors.INVALID_RECIPIENT; //TODO is this the right error?
|
||||
throw DiscordApiErrors.INVALID_RECIPIENT; //TODO: is this the right error?
|
||||
}
|
||||
|
||||
await Channel.removeRecipientFromChannel(channel, user_id);
|
||||
|
||||
@@ -7,9 +7,10 @@ import { route } from "..";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
let cfg = Config.get();
|
||||
const { offset, limit, categories } = req.query;
|
||||
let showAllGuilds = Config.get().guild.discovery.showAllGuilds;
|
||||
let configLimit = Config.get().guild.discovery.limit;
|
||||
let showAllGuilds = cfg.guild.discovery.showAllGuilds;
|
||||
let configLimit = cfg.guild.discovery.limit;
|
||||
// ! this only works using SQL querys
|
||||
// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
|
||||
let guilds;
|
||||
@@ -31,7 +32,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
res.send({
|
||||
total: total,
|
||||
guilds: guilds,
|
||||
offset: Number(offset || Config.get().guild.discovery.offset),
|
||||
offset: Number(offset || cfg.guild.discovery.offset),
|
||||
limit: Number(limit || configLimit)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,7 @@ import { route } from "..";
|
||||
const router = Router();
|
||||
|
||||
router.get("/categories", route({}), async (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// Get locale instead
|
||||
// TODO: Get locale instead
|
||||
|
||||
const { locale, primary_only } = req.query;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { route } from "..";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.send({ fingerprint: "", assignments: [], guild_experiments: [] });
|
||||
});
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ const router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
const { guild_id } = req.params;
|
||||
// TODO:
|
||||
// Load from database
|
||||
// Admin control, but for now it allows anyone to be discoverable
|
||||
// TODO: Load from database
|
||||
// TODO: Admin control, but for now it allows anyone to be discoverable
|
||||
|
||||
res.send({
|
||||
guild_id: guild_id,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/subscriptions", route({}), async (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ const router = Router();
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
const { guild_id } = req.params;
|
||||
const guild = await Guild.findOneOrFail({ where: { id: guild_id } });
|
||||
//TODO we should use an enum for guild's features and not hardcoded strings
|
||||
//TODO: we should use an enum for guild's features and not hardcoded strings
|
||||
return res.json(await getVoiceRegions(getIpAdress(req), guild.features.includes("VIP_REGIONS")));
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { generateCode, route } from "@fosscord/api";
|
||||
import { Guild, HTTPError, OrmUtils, Template } from "@fosscord/util";
|
||||
import { route } from "@fosscord/api";
|
||||
import { generateCode, Guild, HTTPError, OrmUtils, Template } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { random, route } from "@fosscord/api";
|
||||
import { Channel, Guild, HTTPError, Invite, Member, OrmUtils, Permissions } from "@fosscord/util";
|
||||
import { route } from "@fosscord/api";
|
||||
import { Channel, Guild, HTTPError, Invite, Member, OrmUtils, Permissions, random } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
@@ -7,9 +7,10 @@ const router: Router = Router();
|
||||
//TODO: create default channel
|
||||
|
||||
router.post("/", route({ body: "GuildCreateSchema", right: "CREATE_GUILDS" }), async (req: Request, res: Response) => {
|
||||
let cfg = Config.get();
|
||||
const body = req.body as GuildCreateSchema;
|
||||
|
||||
const { maxGuilds } = Config.get().limits.user;
|
||||
const { maxGuilds } = cfg.limits.user;
|
||||
const guild_count = await Member.count({ where: { id: req.user_id } });
|
||||
const rights = await getRights(req.user_id);
|
||||
if (guild_count >= maxGuilds && !rights.has("MANAGE_GUILDS")) {
|
||||
@@ -18,7 +19,7 @@ router.post("/", route({ body: "GuildCreateSchema", right: "CREATE_GUILDS" }), a
|
||||
|
||||
const guild = await Guild.createGuild({ ...body, owner_id: req.user_id });
|
||||
|
||||
const { autoJoin } = Config.get().guild;
|
||||
const { autoJoin } = cfg.guild;
|
||||
if (autoJoin.enabled && !autoJoin.guilds?.length) {
|
||||
// @ts-ignore
|
||||
await Config.set({ guild: { autoJoin: { guilds: [guild.id] } } });
|
||||
|
||||
@@ -4,8 +4,9 @@ import { Request, Response, Router } from "express";
|
||||
import fetch from "node-fetch";
|
||||
const router: Router = Router();
|
||||
|
||||
let cfg = Config.get();
|
||||
router.get("/:code", route({}), async (req: Request, res: Response) => {
|
||||
const { allowDiscordTemplates, allowRaws, enabled } = Config.get().templates;
|
||||
const { allowDiscordTemplates, allowRaws, enabled } = cfg.templates;
|
||||
if (!enabled) res.json({ code: 403, message: "Template creation & usage is disabled on this instance." }).sendStatus(403);
|
||||
|
||||
const { code } = req.params;
|
||||
@@ -33,14 +34,14 @@ router.get("/:code", route({}), async (req: Request, res: Response) => {
|
||||
});
|
||||
|
||||
router.post("/:code", route({ body: "GuildTemplateCreateSchema" }), async (req: Request, res: Response) => {
|
||||
const { enabled, allowTemplateCreation, allowDiscordTemplates, allowRaws } = Config.get().templates;
|
||||
const { enabled, allowTemplateCreation, allowDiscordTemplates, allowRaws } = cfg.templates;
|
||||
if (!enabled) return res.json({ code: 403, message: "Template creation & usage is disabled on this instance." }).sendStatus(403);
|
||||
if (!allowTemplateCreation) return res.json({ code: 403, message: "Template creation is disabled on this instance." }).sendStatus(403);
|
||||
|
||||
const { code } = req.params;
|
||||
const body = req.body as GuildTemplateCreateSchema;
|
||||
|
||||
const { maxGuilds } = Config.get().limits.user;
|
||||
const { maxGuilds } = cfg.limits.user;
|
||||
|
||||
const guild_count = await Member.count({ where: { id: req.user_id } });
|
||||
if (guild_count >= maxGuilds) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "..";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ const router = Router();
|
||||
|
||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
const { guild_id } = req.params;
|
||||
// TODO:
|
||||
// Load from database
|
||||
// Admin control, but for now it allows anyone to be discoverable
|
||||
// TODO: Load from database
|
||||
// TODO: Admin control, but for now it allows anyone to be discoverable
|
||||
|
||||
res.send({
|
||||
guild_id: guild_id,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { Config } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "..";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route?
|
||||
res.sendStatus(204);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route?
|
||||
res.sendStatus(204);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json([]).status(200);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.status(200).send({ guild_affinities: [] });
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.status(200).send({ user_affinities: [], inverse_user_affinities: [] });
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json([]).status(200);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { HTTPError, Member, User } from "@fosscord/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
let bcrypt: any;
|
||||
@@ -24,7 +25,11 @@ router.post("/", route({}), async (req: Request, res: Response) => {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: decrement guild member count
|
||||
(await Member.find({ where: { id: req.user_id }, relations: ["guild"] })).forEach((x) => {
|
||||
let g = x.guild;
|
||||
if (g.member_count) g.member_count--;
|
||||
g.save();
|
||||
});
|
||||
|
||||
if (correctpass) {
|
||||
await Promise.all([User.delete({ id: req.user_id }), Member.delete({ id: req.user_id })]);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.post("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.sendStatus(204);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { User } from "@fosscord/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
let bcrypt: any;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json({
|
||||
categories: {
|
||||
social: true,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/gifts", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json([]).status(200);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "../../../../..";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: implement route
|
||||
res.json([]).status(200);
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
UserModifySchema,
|
||||
UserUpdateEvent
|
||||
} from "@fosscord/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import { Request, Response, Router } from "express";
|
||||
|
||||
let bcrypt: any;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Request, Response, Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
router.get("/", route({}), (req: Request, res: Response) => {
|
||||
// TODO:
|
||||
// TODO: Add library route
|
||||
res.status(200).send([]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { route } from "@fosscord/api";
|
||||
import { BackupCode, Config, FieldErrors, generateMfaBackupCodes, MfaCodesSchema, User } from "@fosscord/util";
|
||||
import bcrypt from "bcrypt";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { route } from "../../../..";
|
||||
|
||||
let bcrypt: any;
|
||||
try {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { route } from "@fosscord/api";
|
||||
import { BackupCode, generateToken, HTTPError, TotpDisableSchema, User } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { verifyToken } from "node-2fa";
|
||||
import { route } from "../../../../..";
|
||||
|
||||
const router = Router();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { route } from "@fosscord/api";
|
||||
import { BackupCode, Config, generateMfaBackupCodes, generateToken, HTTPError, TotpEnableSchema, User } from "@fosscord/util";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { verifyToken } from "node-2fa";
|
||||
import { route } from "../../../../..";
|
||||
|
||||
let bcrypt: any;
|
||||
try {
|
||||
|
||||
@@ -25,7 +25,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
||||
select: ["relationships"]
|
||||
});
|
||||
|
||||
//TODO DTO
|
||||
//TODO: DTO
|
||||
const related_users = user.relationships.map((r) => {
|
||||
return {
|
||||
id: r.to.id,
|
||||
@@ -181,7 +181,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
|
||||
if (friendRequest.type === RelationshipType.blocked) throw new HTTPError("The user blocked you");
|
||||
if (friendRequest.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
|
||||
// accept friend request
|
||||
incoming_relationship = friendRequest as any; //TODO: checkme, any cast
|
||||
incoming_relationship = friendRequest;
|
||||
incoming_relationship.type = RelationshipType.friends;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ
|
||||
if (relationship.type === RelationshipType.outgoing) throw new HTTPError("You already sent a friend request");
|
||||
if (relationship.type === RelationshipType.blocked) throw new HTTPError("Unblock the user before sending a friend request");
|
||||
if (relationship.type === RelationshipType.friends) throw new HTTPError("You are already friends with the user");
|
||||
outgoing_relationship = relationship as any; //TODO: checkme, any cast
|
||||
outgoing_relationship = relationship;
|
||||
outgoing_relationship.type = RelationshipType.friends;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getIpAdress, getVoiceRegions, route } from "@fosscord/api";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { getIpAdress, getVoiceRegions, route } from "../..";
|
||||
|
||||
const router: Router = Router();
|
||||
|
||||
|
||||
@@ -18,16 +18,11 @@ import {
|
||||
MessageType,
|
||||
MessageUpdateEvent,
|
||||
OrmUtils,
|
||||
PluginEventHandler,
|
||||
PreMessageEventArgs,
|
||||
Role,
|
||||
ROLE_MENTION,
|
||||
User,
|
||||
Application,
|
||||
Webhook,
|
||||
Attachment,
|
||||
Config,
|
||||
MessageCreateSchema,
|
||||
PluginEventHandler,
|
||||
PreMessageEventArgs,
|
||||
USER_MENTION,
|
||||
Webhook
|
||||
} from "@fosscord/util";
|
||||
@@ -212,11 +207,15 @@ export async function postHandleMessage(message: Message) {
|
||||
export async function sendMessage(opts: MessageOptions) {
|
||||
const message = await handleMessage({ ...opts, timestamp: new Date() });
|
||||
|
||||
if((await PluginEventHandler.preMessageEvent({
|
||||
message
|
||||
} as PreMessageEventArgs)).filter(x=>x.cancel).length > 0) return;
|
||||
if (
|
||||
(
|
||||
await PluginEventHandler.preMessageEvent({
|
||||
message
|
||||
} as PreMessageEventArgs)
|
||||
).filter((x) => x.cancel).length > 0
|
||||
)
|
||||
return;
|
||||
|
||||
//TODO: check this, removed toJSON call
|
||||
await Promise.all([
|
||||
Message.insert(message),
|
||||
emitEvent({ event: "MESSAGE_CREATE", channel_id: opts.channel_id, data: message } as MessageCreateEvent)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Config } from "@fosscord/util";
|
||||
import { distanceBetweenLocations, IPAnalysis } from "../utility/ipAddress";
|
||||
import { distanceBetweenLocations, IPAnalysis } from "../../../util/util/ipAddress";
|
||||
|
||||
export async function getVoiceRegions(ipAddress: string, vip: boolean) {
|
||||
const regions = Config.get().regions;
|
||||
@@ -12,7 +12,7 @@ export async function getVoiceRegions(ipAddress: string, vip: boolean) {
|
||||
let min = Number.POSITIVE_INFINITY;
|
||||
|
||||
for (let ar of availableRegions) {
|
||||
//TODO the endpoint location should be saved in the database if not already present to prevent IPAnalysis call
|
||||
//TODO: the endpoint location should be saved in the database if not already present to prevent IPAnalysis call
|
||||
const dist = distanceBetweenLocations(clientIpAnalysis, ar.location || (await IPAnalysis(ar.endpoint)));
|
||||
|
||||
if (dist < min) {
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
export * from "../../util/util/Base64";
|
||||
export * from "../../util/util/ipAddress";
|
||||
export * from "./entities/AssetCacheItem";
|
||||
export * from "./handlers/Message";
|
||||
export * from "./handlers/route";
|
||||
export * from "./handlers/Voice";
|
||||
export * from "./utility/Base64";
|
||||
export * from "./utility/captcha";
|
||||
export * from "./utility/ipAddress";
|
||||
export * from "./utility/passwordStrength";
|
||||
export * from "./utility/RandomInviteID";
|
||||
export * from "./utility/String";
|
||||
export * from "./utility/captcha";
|
||||
export * from "./TestClientPatcher";
|
||||
@@ -1,18 +0,0 @@
|
||||
import { FieldErrors } from "@fosscord/util";
|
||||
import { Request } from "express";
|
||||
import { ntob } from "./Base64";
|
||||
|
||||
export function checkLength(str: string, min: number, max: number, key: string, req: Request) {
|
||||
if (str.length < min || str.length > max) {
|
||||
throw FieldErrors({
|
||||
[key]: {
|
||||
code: "BASE_TYPE_BAD_LENGTH",
|
||||
message: req.t("common:field.BASE_TYPE_BAD_LENGTH", { length: `${min} - ${max}` })
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function generateCode() {
|
||||
return ntob(Date.now() + Math.randomIntBetween(0, 10000));
|
||||
}
|
||||
+1
-2
@@ -2,11 +2,10 @@ import { Config, getOrInitialiseDatabase, registerRoutes } from "@fosscord/util"
|
||||
import bodyParser from "body-parser";
|
||||
import { Server, ServerOptions } from "lambert-server";
|
||||
import path from "path";
|
||||
import { PluginConfig } from "../util/plugin/PluginConfig";
|
||||
import avatarsRoute from "./routes/avatars";
|
||||
import guildProfilesRoute from "./routes/guild-profiles";
|
||||
import iconsRoute from "./routes/role-icons";
|
||||
import bodyParser from "body-parser";
|
||||
import { PluginConfig } from "util/plugin/PluginConfig";
|
||||
|
||||
export interface CDNServerOptions extends ServerOptions {}
|
||||
|
||||
|
||||
+19
-16
@@ -1,5 +1,5 @@
|
||||
import fs from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import path, { dirname, join } from "path";
|
||||
import { Readable } from "stream";
|
||||
import { Storage } from "./Storage";
|
||||
//import ExifTransformer = require("exif-be-gone");
|
||||
@@ -7,44 +7,47 @@ import ExifTransformer from "exif-be-gone";
|
||||
|
||||
// TODO: split stored files into separate folders named after cloned route
|
||||
|
||||
function getPath(path: string) {
|
||||
function getPath(filePath: string) {
|
||||
// STORAGE_LOCATION has a default value in start.ts
|
||||
const root = process.env.STORAGE_LOCATION || "../";
|
||||
let filename = join(root, path);
|
||||
let filename = join(root, filePath);
|
||||
|
||||
if (path.indexOf("\0") !== -1 || !filename.startsWith(root)) throw new Error("invalid path");
|
||||
if (filePath.indexOf("\0") !== -1 || !filename.startsWith(root)) throw new Error("invalid path");
|
||||
return filename;
|
||||
}
|
||||
|
||||
export class FileStorage implements Storage {
|
||||
async get(path: string): Promise<Buffer | null> {
|
||||
path = getPath(path);
|
||||
async get(filePath: string): Promise<Buffer | null> {
|
||||
filePath = getPath(filePath);
|
||||
try {
|
||||
return fs.readFileSync(path);
|
||||
return fs.readFileSync(filePath);
|
||||
} catch (error) {
|
||||
try {
|
||||
const files = fs.readdirSync(path);
|
||||
const files = fs.readdirSync(filePath);
|
||||
if (!files.length) return null;
|
||||
return fs.readFileSync(join(path, files[0]));
|
||||
return fs.readFileSync(join(filePath, files[0]));
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async set(path: string, value: any) {
|
||||
path = getPath(path);
|
||||
async set(filePath: string, value: any) {
|
||||
filePath = getPath(filePath);
|
||||
//fse.ensureDirSync(dirname(path));
|
||||
fs.mkdirSync(dirname(path), { recursive: true });
|
||||
fs.mkdirSync(dirname(filePath), { recursive: true });
|
||||
|
||||
value = Readable.from(value);
|
||||
const cleaned_file = fs.createWriteStream(path);
|
||||
const cleaned_file = fs.createWriteStream(filePath);
|
||||
|
||||
return value.pipe(new ExifTransformer()).pipe(cleaned_file);
|
||||
}
|
||||
|
||||
async delete(path: string) {
|
||||
//TODO we should delete the parent directory if empty
|
||||
fs.unlinkSync(getPath(path));
|
||||
async delete(filePath: string) {
|
||||
//TODO: (done?) we should delete the parent directory if empty
|
||||
fs.unlinkSync(getPath(filePath));
|
||||
if (fs.readdirSync(path.dirname(filePath)).length == 0) {
|
||||
fs.rmSync(path.dirname(filePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@ import { closeDatabase, Config, getOrInitialiseDatabase, initEvent } from "@foss
|
||||
import dotenv from "dotenv";
|
||||
import http from "http";
|
||||
import ws from "ws";
|
||||
import { PluginConfig } from "../util/plugin/PluginConfig";
|
||||
import { Connection } from "./events/Connection";
|
||||
import http from "http";
|
||||
import { PluginConfig } from "util/plugin/PluginConfig";
|
||||
dotenv.config();
|
||||
|
||||
export class Server {
|
||||
|
||||
@@ -77,7 +77,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
// TODO: check if status is only one of: online, dnd, offline, idle
|
||||
status: identify.presence?.status || "offline", //does the session always start as online?
|
||||
client_info: {
|
||||
//TODO read from identity
|
||||
//TODO: read from identity
|
||||
client: "desktop",
|
||||
os: identify.properties?.os,
|
||||
version: 0
|
||||
@@ -147,7 +147,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
const channels = recipients.map((x) => {
|
||||
// @ts-ignore
|
||||
x.channel.recipients = x.channel.recipients?.map((x) => x.user);
|
||||
//TODO is this needed? check if users in group dm that are not friends are sent in the READY event
|
||||
//TODO: is this needed? check if users in group dm that are not friends are sent in the READY event
|
||||
users = users.concat(x.channel.recipients as unknown as User[]);
|
||||
if (x.channel.isDm()) {
|
||||
x.channel.recipients = x.channel.recipients!.filter((x) => x.id !== this.user_id);
|
||||
@@ -274,10 +274,10 @@ export async function onIdentify(this: WebSocket, data: Payload) {
|
||||
d
|
||||
});
|
||||
|
||||
//TODO send READY_SUPPLEMENTAL
|
||||
//TODO send GUILD_MEMBER_LIST_UPDATE
|
||||
//TODO send SESSIONS_REPLACE
|
||||
//TODO send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
||||
//TODO: send READY_SUPPLEMENTAL
|
||||
//TODO: send GUILD_MEMBER_LIST_UPDATE
|
||||
//TODO: send SESSIONS_REPLACE
|
||||
//TODO: send VOICE_STATE_UPDATE to let the client know if another device is already connected to a voice channel
|
||||
|
||||
await setupListener.call(this);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function onPresenceUpdate(this: WebSocket, { d }: Payload) {
|
||||
data: {
|
||||
user: await User.getPublicUser(this.user_id),
|
||||
activities: presence.activities,
|
||||
client_status: {}, // TODO:
|
||||
client_status: {}, // TODO: add client status
|
||||
status: presence.status
|
||||
}
|
||||
} as PresenceUpdateEvent);
|
||||
|
||||
@@ -58,9 +58,9 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
|
||||
});
|
||||
}
|
||||
|
||||
//TODO the member should only have these properties: hoisted_role, deaf, joined_at, mute, roles, user
|
||||
//TODO the member.user should only have these properties: avatar, discriminator, id, username
|
||||
//TODO this may fail
|
||||
//TODO: the member should only have these properties: hoisted_role, deaf, joined_at, mute, roles, user
|
||||
//TODO: the member.user should only have these properties: avatar, discriminator, id, username
|
||||
//TODO: this may fail
|
||||
voiceState.member = await Member.findOneOrFail({
|
||||
where: { id: voiceState.user_id, guild_id: voiceState.guild_id },
|
||||
relations: ["user", "roles"]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Plugin } from "util/plugin";
|
||||
import * as example_plugin from "./example-plugin/TestPlugin";
|
||||
|
||||
export const PluginIndex: any = {
|
||||
"example-plugin": new example_plugin.default(),
|
||||
};
|
||||
"example-plugin": new example_plugin.default()
|
||||
};
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
import { setupListener } from "@fosscord/gateway";
|
||||
import { Channel, Guild, Plugin, PluginLoadedEventArgs, PluginLoader, PluginManifest, PreMessageEventArgs, PreMessageEventResult } from "@fosscord/util";
|
||||
import {
|
||||
Channel,
|
||||
Guild,
|
||||
Plugin,
|
||||
PluginLoadedEventArgs,
|
||||
PluginLoader,
|
||||
PluginManifest,
|
||||
PreMessageEventArgs,
|
||||
PreMessageEventResult
|
||||
} from "@fosscord/util";
|
||||
import { TestSettings } from "./TestSettings";
|
||||
|
||||
export default class TestPlugin implements Plugin {
|
||||
pluginManifest?: PluginManifest | undefined;
|
||||
settings: TestSettings = new TestSettings();
|
||||
async onPluginLoaded(env: PluginLoadedEventArgs) {
|
||||
console.log("Test plugin active!");
|
||||
if(this.pluginManifest) this.settings = PluginLoader.getPluginConfig(this.pluginManifest.id, this.settings) as TestSettings;
|
||||
}
|
||||
async onPreMessage(data: PreMessageEventArgs): Promise<PreMessageEventResult> {
|
||||
let channel = await Channel.findOne({ where: { id: data.message.channel_id } });
|
||||
let guild = await Guild.findOne({ where: { id: data.message.guild_id } });
|
||||
let block = data.message.content?.includes('UwU');
|
||||
|
||||
let result = {cancel: block} as PreMessageEventResult;
|
||||
pluginManifest?: PluginManifest | undefined;
|
||||
settings: TestSettings = new TestSettings();
|
||||
async onPluginLoaded(env: PluginLoadedEventArgs) {
|
||||
console.log("Test plugin active!");
|
||||
if (this.pluginManifest) this.settings = PluginLoader.getPluginConfig(this.pluginManifest.id, this.settings) as TestSettings;
|
||||
}
|
||||
async onPreMessage(data: PreMessageEventArgs): Promise<PreMessageEventResult> {
|
||||
let channel = await Channel.findOne({ where: { id: data.message.channel_id } });
|
||||
let guild = await Guild.findOne({ where: { id: data.message.guild_id } });
|
||||
let block = data.message.content?.includes("UwU");
|
||||
|
||||
if(block) {
|
||||
console.log(`[TestPlugin] Blocked message in ${guild?.name}/#${channel?.name} by ${data.message.author?.username}: ${data.message.content}`);
|
||||
result.blockReason = "[TestPlugin] Your message contains UwU! Get bamboozled!";
|
||||
}
|
||||
let result = { cancel: block } as PreMessageEventResult;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (block) {
|
||||
console.log(
|
||||
`[TestPlugin] Blocked message in ${guild?.name}/#${channel?.name} by ${data.message.author?.username}: ${data.message.content}`
|
||||
);
|
||||
result.blockReason = "[TestPlugin] Your message contains UwU! Get bamboozled!";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export class TestSettings {
|
||||
someInt: number = 10;
|
||||
someStr: string = "asdf";
|
||||
someBool: boolean = true;
|
||||
someDate: Date = new Date();
|
||||
subSettings: SubSettings = new SubSettings();
|
||||
someInt: number = 10;
|
||||
someStr: string = "asdf";
|
||||
someBool: boolean = true;
|
||||
someDate: Date = new Date();
|
||||
subSettings: SubSettings = new SubSettings();
|
||||
}
|
||||
|
||||
export class SubSettings {
|
||||
someStr: string = "jklm";
|
||||
}
|
||||
someStr: string = "jklm";
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
{
|
||||
"id": "example-plugin",
|
||||
"name": "Fosscord example plugin",
|
||||
"authors": [
|
||||
"The Arcane Brony"
|
||||
],
|
||||
"repository": "https://github.com/fosscord/fosscord-server",
|
||||
"license": "",
|
||||
"mainClass": "TestPlugin"
|
||||
"id": "example-plugin",
|
||||
"name": "Fosscord example plugin",
|
||||
"authors": ["The Arcane Brony"],
|
||||
"repository": "https://github.com/fosscord/fosscord-server",
|
||||
"license": "",
|
||||
"mainClass": "TestPlugin"
|
||||
}
|
||||
|
||||
+5
-11
@@ -6,9 +6,8 @@ import os from "os";
|
||||
import { bold, cyan, red, yellow } from "picocolors";
|
||||
import "reflect-metadata";
|
||||
import { initStats } from "./stats";
|
||||
config();
|
||||
import { execSync } from "child_process";
|
||||
import { Logo } from "./util";
|
||||
config();
|
||||
|
||||
// TODO: add socket event transmission
|
||||
let cores = 1;
|
||||
@@ -27,15 +26,10 @@ if (cluster.isMaster) {
|
||||
}
|
||||
}
|
||||
const commit = getCommitOrFail();
|
||||
Logo.printLogo();
|
||||
console.log(bold(`
|
||||
fosscord-server | ${yellow(
|
||||
`Pre-release (${
|
||||
commit !== null
|
||||
? commit.slice(0, 7)
|
||||
: "Unknown (Git cannot be found)"
|
||||
})`
|
||||
)}
|
||||
Logo.printLogo();
|
||||
console.log(
|
||||
bold(`
|
||||
fosscord-server | ${yellow(`Pre-release (${commit !== null ? commit.slice(0, 7) : "Unknown (Git cannot be found)"})`)}
|
||||
|
||||
Commit Hash: ${commit !== null ? `${cyan(commit)} (${yellow(commit.slice(0, 7))})` : "Unknown (Git cannot be found)"}
|
||||
Cores: ${cyan(os.cpus().length)} (Using ${cores} thread(s).)
|
||||
|
||||
@@ -20,12 +20,12 @@ import {
|
||||
|
||||
export class ConfigValue {
|
||||
gateway: EndpointConfiguration = {
|
||||
endpointPublic: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}',
|
||||
endpointPrivate: `ws://localhost:3001`
|
||||
endpointPrivate: `ws://localhost:3001`,
|
||||
endpointPublic: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}'
|
||||
};
|
||||
cdn: EndpointConfiguration = {
|
||||
endpointPublic: "${location.host}",
|
||||
endpointPrivate: `http://localhost:3001`
|
||||
endpointPrivate: `http://localhost:3001`,
|
||||
endpointPublic: "${location.host}"
|
||||
};
|
||||
api: ApiConfiguration = new ApiConfiguration();
|
||||
general: GeneralConfiguration = new GeneralConfiguration();
|
||||
|
||||
@@ -359,8 +359,8 @@ export class Channel extends BaseClass {
|
||||
}
|
||||
|
||||
static async deleteChannel(channel: Channel) {
|
||||
await Message.delete({ channel_id: channel.id }); //TODO we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util
|
||||
//TODO before deleting the channel we should check and delete other relations
|
||||
await Message.delete({ channel_id: channel.id }); //TODO: we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util
|
||||
//TODO: before deleting the channel we should check and delete other relations
|
||||
await Channel.delete({ id: channel.id });
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Webhook } from "./Webhook";
|
||||
// TODO: guild_scheduled_events
|
||||
// TODO: stage_instances
|
||||
// TODO: threads
|
||||
// TODO:
|
||||
// TODO: implement keywords
|
||||
// "keywords": [
|
||||
// "Genshin Impact",
|
||||
// "Paimon",
|
||||
@@ -75,7 +75,7 @@ export class Guild extends BaseClass {
|
||||
explicit_content_filter?: number = Config.get().defaults.guild.explicitContentFilter;
|
||||
|
||||
@Column({ type: "simple-array" })
|
||||
features: string[]; //TODO use enum
|
||||
features: string[]; //TODO: use enum
|
||||
//TODO: https://discord.com/developers/docs/resources/guild#guild-object-guild-features
|
||||
|
||||
@Column({ nullable: true })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { random } from "@fosscord/api";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm";
|
||||
import { random } from "..";
|
||||
import { BaseClassWithoutId } from "./BaseClass";
|
||||
import { Channel } from "./Channel";
|
||||
import { Guild } from "./Guild";
|
||||
|
||||
@@ -8,4 +8,4 @@ export class PluginConfigEntity extends BaseClassWithoutId {
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
value: number | boolean | null | string | Date | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Status } from "../interfaces/Status";
|
||||
import { BaseClass } from "./BaseClass";
|
||||
import { User } from "./User";
|
||||
|
||||
//TODO we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
|
||||
//TODO: we need to remove all sessions on server start because if the server crashes without closing websockets it won't delete them
|
||||
|
||||
@Entity("sessions")
|
||||
export class Session extends BaseClass {
|
||||
@@ -18,7 +18,7 @@ export class Session extends BaseClass {
|
||||
})
|
||||
user: User;
|
||||
|
||||
//TODO check, should be 32 char long hex string
|
||||
//TODO: check, should be 32 char long hex string
|
||||
@Column({ nullable: false, select: false })
|
||||
session_id: string;
|
||||
|
||||
@@ -34,7 +34,7 @@ export class Session extends BaseClass {
|
||||
};
|
||||
|
||||
@Column({ nullable: false, type: "varchar" })
|
||||
status: Status; //TODO enum
|
||||
status: Status; //TODO: enum
|
||||
}
|
||||
|
||||
export const PrivateSessionProjection: (keyof Session)[] = ["user_id", "session_id", "activities", "client_info", "status"];
|
||||
|
||||
@@ -250,7 +250,7 @@ export class User extends BaseClass {
|
||||
* date_of_birth,
|
||||
* req,
|
||||
* }
|
||||
* @return {*}
|
||||
* @return {*}
|
||||
* @memberof User
|
||||
*/
|
||||
static async register({
|
||||
|
||||
@@ -42,7 +42,7 @@ export class VoiceState extends BaseClass {
|
||||
// @ManyToOne(() => Member, {
|
||||
// onDelete: "CASCADE",
|
||||
// })
|
||||
//TODO find a way to make it work without breaking Guild.voice_states
|
||||
//TODO: find a way to make it work without breaking Guild.voice_states
|
||||
member: Member;
|
||||
|
||||
@Column()
|
||||
|
||||
@@ -16,6 +16,7 @@ export * from "./Member";
|
||||
export * from "./Message";
|
||||
export * from "./Migration";
|
||||
export * from "./Note";
|
||||
export * from "./PluginConfig";
|
||||
export * from "./RateLimit";
|
||||
export * from "./ReadState";
|
||||
export * from "./Recipient";
|
||||
@@ -31,8 +32,3 @@ export * from "./User";
|
||||
export * from "./UserSettings";
|
||||
export * from "./VoiceState";
|
||||
export * from "./Webhook";
|
||||
export * from "./ClientRelease";
|
||||
export * from "./BackupCodes";
|
||||
export * from "./Note";
|
||||
export * from "./UserSettings";
|
||||
export * from "./PluginConfig";
|
||||
|
||||
+1
-2
@@ -4,8 +4,7 @@ export * from "./config/index";
|
||||
export * from "./dtos/index";
|
||||
export * from "./entities/index";
|
||||
export * from "./interfaces/index";
|
||||
export * from "./plugin";
|
||||
export * from "./schemas";
|
||||
export * from "./util/index";
|
||||
export * from "./util/MFA";
|
||||
export * from "./schemas";
|
||||
export * from "./plugin";
|
||||
@@ -1,42 +1,41 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class PluginConfigs1660404644371 implements MigrationInterface {
|
||||
name = 'PluginConfigs1660404644371'
|
||||
name = "PluginConfigs1660404644371";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE \`plugin_config\` (
|
||||
\`key\` varchar(255) NOT NULL,
|
||||
\`value\` text NULL,
|
||||
PRIMARY KEY (\`key\`)
|
||||
) ENGINE = InnoDB
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\`
|
||||
ADD \`flags\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\`
|
||||
ADD \`default_thread_rate_limit_per_user\` int NULL
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE \`plugin_config\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`)
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,229 +1,228 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateMigrations1660534571948 implements MigrationInterface {
|
||||
name = 'UpdateMigrations1660534571948'
|
||||
name = "UpdateMigrations1660534571948";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_e5bf78cdbbe9ba91062d74c5aba\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE \`plugin_config\` (
|
||||
\`key\` varchar(255) NOT NULL,
|
||||
\`value\` text NULL,
|
||||
PRIMARY KEY (\`key\`)
|
||||
) ENGINE = InnoDB
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`rpc_origins\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`primary_sku_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`slug\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`guild_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`type\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`hook\` tinyint NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`redirect_uris\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`rpc_application_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`store_application_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`verification_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`interactions_endpoint_url\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`integration_public\` tinyint NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`integration_require_code_grant\` tinyint NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`discoverability_state\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`discovery_eligibility_flags\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`tags\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`install_params\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`bot_user_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD UNIQUE INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\` (\`bot_user_id\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\`
|
||||
ADD \`flags\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\`
|
||||
ADD \`default_thread_rate_limit_per_user\` int NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`flags\` int NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\` (\`bot_user_id\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD CONSTRAINT \`FK_2ce5a55796fe4c2f77ece57a647\` FOREIGN KEY (\`bot_user_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`invites\`
|
||||
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`invites\` DROP FOREIGN KEY \`FK_15c35422032e0b22b4ada95f48f\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP FOREIGN KEY \`FK_2ce5a55796fe4c2f77ece57a647\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP INDEX \`REL_2ce5a55796fe4c2f77ece57a64\` ON \`applications\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`flags\` varchar(255) NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` CHANGE \`description\` \`description\` varchar(255) NOT NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\` DROP COLUMN \`default_thread_rate_limit_per_user\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`channels\` DROP COLUMN \`flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP INDEX \`IDX_2ce5a55796fe4c2f77ece57a64\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`bot_user_id\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`install_params\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`tags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`discovery_eligibility_flags\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`discoverability_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`integration_require_code_grant\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`integration_public\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`interactions_endpoint_url\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`verification_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`store_application_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`rpc_application_state\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`redirect_uris\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`hook\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\` DROP COLUMN \`type\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`guild_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`slug\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`primary_sku_id\` varchar(255) NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD \`rpc_origins\` text NULL
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE \`plugin_config\`
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE UNIQUE INDEX \`IDX_76ba283779c8441fd5ff819c8c\` ON \`users\` (\`settingsId\`)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`invites\`
|
||||
ADD CONSTRAINT \`FK_15c35422032e0b22b4ada95f48f\` FOREIGN KEY (\`inviter_id\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE \`applications\`
|
||||
ADD CONSTRAINT \`FK_e5bf78cdbbe9ba91062d74c5aba\` FOREIGN KEY (\`guild_id\`) REFERENCES \`guilds\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class PluginConfigs1660404619978 implements MigrationInterface {
|
||||
name = 'PluginConfigs1660404619978'
|
||||
name = "PluginConfigs1660404619978";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "plugin_config" (
|
||||
"key" character varying NOT NULL,
|
||||
"value" text,
|
||||
CONSTRAINT "PK_aa929ece56c59233b85a16f62ef" PRIMARY KEY ("key")
|
||||
)
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "plugin_config"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
name = 'UpdateMigrations1660534525799'
|
||||
name = "UpdateMigrations1660534525799";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -28,7 +28,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -69,14 +69,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"guild_id"
|
||||
FROM "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_applications"
|
||||
RENAME TO "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -96,7 +96,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -129,14 +129,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"team_id"
|
||||
FROM "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_applications"
|
||||
RENAME TO "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -171,7 +171,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -204,14 +204,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"team_id"
|
||||
FROM "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_applications"
|
||||
RENAME TO "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -246,7 +246,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -307,14 +307,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"bot_user_id"
|
||||
FROM "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_applications"
|
||||
RENAME TO "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "temporary_applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -350,7 +350,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_2ce5a55796fe4c2f77ece57a647" FOREIGN KEY ("bot_user_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "temporary_applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -411,21 +411,21 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"bot_user_id"
|
||||
FROM "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "temporary_applications"
|
||||
RENAME TO "applications"
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "applications"
|
||||
RENAME TO "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -460,7 +460,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -521,14 +521,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"bot_user_id"
|
||||
FROM "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "applications"
|
||||
RENAME TO "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -563,7 +563,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -624,14 +624,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"bot_user_id"
|
||||
FROM "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "applications"
|
||||
RENAME TO "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -651,7 +651,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -684,14 +684,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"team_id"
|
||||
FROM "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "applications"
|
||||
RENAME TO "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -715,7 +715,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -748,14 +748,14 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"team_id"
|
||||
FROM "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "applications"
|
||||
RENAME TO "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "applications" (
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
@@ -780,7 +780,7 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
CONSTRAINT "FK_e57508958bf92b9d9d25231b5e8" FOREIGN KEY ("owner_id") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
INSERT INTO "applications"(
|
||||
"id",
|
||||
"name",
|
||||
@@ -821,9 +821,8 @@ export class UpdateMigrations1660534525799 implements MigrationInterface {
|
||||
"guild_id"
|
||||
FROM "temporary_applications"
|
||||
`);
|
||||
await queryRunner.query(`
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "temporary_applications"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class syncRebase15aug20221660565540177 implements MigrationInterface {
|
||||
name = 'syncRebase15aug20221660565540177'
|
||||
name = "syncRebase15aug20221660565540177";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "plugin_config" ("key" varchar PRIMARY KEY NOT NULL, "value" text)
|
||||
`);
|
||||
}
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
DROP TABLE "plugin_config"
|
||||
`);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+110
-100
@@ -1,14 +1,27 @@
|
||||
import EventEmitter from "events";
|
||||
import { PluginLoadedEventArgs, PluginManifest, TypedEventEmitter } from "@fosscord/util";
|
||||
import { PluginConfig } from "./PluginConfig";
|
||||
import { PreRegisterEventArgs, PreRegisterEventResult, OnRegisterEventArgs } from '.';
|
||||
import { PreMessageEventArgs, PreMessageEventResult, OnMessageEventArgs } from '.';
|
||||
import { PreLoginEventArgs, PreLoginEventResult, OnLoginEventArgs } from '.';
|
||||
import { PreGuildCreateEventArgs, PreGuildCreateEventResult, OnGuildCreateEventArgs } from '.';
|
||||
import { PreChannelCreateEventArgs, PreChannelCreateEventResult, OnChannelCreateEventArgs } from '.';
|
||||
import { PreTypingEventArgs, PreTypingEventResult, OnTypingEventArgs } from '.';
|
||||
import { PreStatusChangeEventArgs, PreStatusChangeEventResult, OnStatusChangeEventArgs } from '.';
|
||||
|
||||
import {
|
||||
OnChannelCreateEventArgs,
|
||||
OnGuildCreateEventArgs,
|
||||
OnLoginEventArgs,
|
||||
OnMessageEventArgs,
|
||||
OnRegisterEventArgs,
|
||||
OnStatusChangeEventArgs,
|
||||
OnTypingEventArgs,
|
||||
PreChannelCreateEventArgs,
|
||||
PreChannelCreateEventResult,
|
||||
PreGuildCreateEventArgs,
|
||||
PreGuildCreateEventResult,
|
||||
PreLoginEventArgs,
|
||||
PreLoginEventResult,
|
||||
PreMessageEventArgs,
|
||||
PreMessageEventResult,
|
||||
PreRegisterEventArgs,
|
||||
PreRegisterEventResult,
|
||||
PreStatusChangeEventArgs,
|
||||
PreStatusChangeEventResult,
|
||||
PreTypingEventArgs,
|
||||
PreTypingEventResult
|
||||
} from ".";
|
||||
import { PluginLoadedEventArgs, PluginManifest } from "..";
|
||||
|
||||
/*type PluginEvents = {
|
||||
error: (error: Error | unknown) => void;
|
||||
@@ -27,134 +40,131 @@ export class Plugin {
|
||||
pluginPath?: string;
|
||||
pluginManifest?: PluginManifest;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param {PluginLoadedEventArgs} args Info about plugin environment
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPluginLoaded?(args?: PluginLoadedEventArgs) {
|
||||
|
||||
}
|
||||
async onPluginLoaded?(args?: PluginLoadedEventArgs) {}
|
||||
|
||||
//generated
|
||||
/**
|
||||
* RegisterEvent: document me
|
||||
*
|
||||
* @param {OnRegisterEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* RegisterEvent: document me
|
||||
*
|
||||
* @param {OnRegisterEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onRegister?(args: OnRegisterEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* RegisterEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreRegisterEventArgs} args Info about what's going on
|
||||
* @return {PreRegisterEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* RegisterEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreRegisterEventArgs} args Info about what's going on
|
||||
* @return {PreRegisterEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreRegister?(args: PreRegisterEventArgs): Promise<PreRegisterEventResult>;
|
||||
/**
|
||||
* MessageEvent: document me
|
||||
*
|
||||
* @param {OnMessageEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* MessageEvent: document me
|
||||
*
|
||||
* @param {OnMessageEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onMessage?(args: OnMessageEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* MessageEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreMessageEventArgs} args Info about what's going on
|
||||
* @return {PreMessageEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* MessageEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreMessageEventArgs} args Info about what's going on
|
||||
* @return {PreMessageEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreMessage?(args: PreMessageEventArgs): Promise<PreMessageEventResult>;
|
||||
/**
|
||||
* LoginEvent: document me
|
||||
*
|
||||
* @param {OnLoginEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* LoginEvent: document me
|
||||
*
|
||||
* @param {OnLoginEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onLogin?(args: OnLoginEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* LoginEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreLoginEventArgs} args Info about what's going on
|
||||
* @return {PreLoginEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* LoginEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreLoginEventArgs} args Info about what's going on
|
||||
* @return {PreLoginEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreLogin?(args: PreLoginEventArgs): Promise<PreLoginEventResult>;
|
||||
/**
|
||||
* GuildCreateEvent: document me
|
||||
*
|
||||
* @param {OnGuildCreateEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* GuildCreateEvent: document me
|
||||
*
|
||||
* @param {OnGuildCreateEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onGuildCreate?(args: OnGuildCreateEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* GuildCreateEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreGuildCreateEventArgs} args Info about what's going on
|
||||
* @return {PreGuildCreateEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* GuildCreateEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreGuildCreateEventArgs} args Info about what's going on
|
||||
* @return {PreGuildCreateEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreGuildCreate?(args: PreGuildCreateEventArgs): Promise<PreGuildCreateEventResult>;
|
||||
/**
|
||||
* ChannelCreateEvent: document me
|
||||
*
|
||||
* @param {OnChannelCreateEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* ChannelCreateEvent: document me
|
||||
*
|
||||
* @param {OnChannelCreateEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onChannelCreate?(args: OnChannelCreateEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* ChannelCreateEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreChannelCreateEventArgs} args Info about what's going on
|
||||
* @return {PreChannelCreateEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* ChannelCreateEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreChannelCreateEventArgs} args Info about what's going on
|
||||
* @return {PreChannelCreateEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreChannelCreate?(args: PreChannelCreateEventArgs): Promise<PreChannelCreateEventResult>;
|
||||
/**
|
||||
* TypingEvent: document me
|
||||
*
|
||||
* @param {OnTypingEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* TypingEvent: document me
|
||||
*
|
||||
* @param {OnTypingEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onTyping?(args: OnTypingEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* TypingEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreTypingEventArgs} args Info about what's going on
|
||||
* @return {PreTypingEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* TypingEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreTypingEventArgs} args Info about what's going on
|
||||
* @return {PreTypingEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreTyping?(args: PreTypingEventArgs): Promise<PreTypingEventResult>;
|
||||
/**
|
||||
* StatusChangeEvent: document me
|
||||
*
|
||||
* @param {OnStatusChangeEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* StatusChangeEvent: document me
|
||||
*
|
||||
* @param {OnStatusChangeEventArgs} args Info about what's going on
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onStatusChange?(args: OnStatusChangeEventArgs): Promise<void>;
|
||||
|
||||
/**
|
||||
* StatusChangeEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreStatusChangeEventArgs} args Info about what's going on
|
||||
* @return {PreStatusChangeEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
* StatusChangeEvent: Executed before changes are announced
|
||||
* document me.
|
||||
*
|
||||
* @param {PreStatusChangeEventArgs} args Info about what's going on
|
||||
* @return {PreStatusChangeEventResult} How event should be handled
|
||||
* @memberof Plugin
|
||||
*/
|
||||
async onPreStatusChange?(args: PreStatusChangeEventArgs): Promise<PreStatusChangeEventResult>;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "fs";
|
||||
import { OrmUtils, Environment } from "..";
|
||||
import { PluginConfigEntity } from "util/entities/PluginConfig";
|
||||
import { Environment } from "..";
|
||||
import { PluginConfigEntity } from "../entities/PluginConfig";
|
||||
|
||||
// TODO: yaml instead of json
|
||||
const overridePath = process.env.PLUGIN_CONFIG_PATH ?? "";
|
||||
@@ -14,26 +14,28 @@ let pairs: PluginConfigEntity[];
|
||||
export const PluginConfig = {
|
||||
init: async function init() {
|
||||
if (config) return config;
|
||||
console.log('[PluginConfig] Loading configuration...')
|
||||
console.log("[PluginConfig] Loading configuration...");
|
||||
pairs = await PluginConfigEntity.find();
|
||||
config = pairsToConfig(pairs);
|
||||
//config = (config || {}).merge(new ConfigValue());
|
||||
//config = OrmUtils.mergeDeep(new ConfigValue(), config)
|
||||
|
||||
if(process.env.PLUGIN_CONFIG_PATH)
|
||||
if (process.env.PLUGIN_CONFIG_PATH)
|
||||
try {
|
||||
const overrideConfig = JSON.parse(fs.readFileSync(overridePath, { encoding: "utf8" }));
|
||||
config = overrideConfig.merge(config);
|
||||
} catch (error) {
|
||||
fs.writeFileSync(overridePath, JSON.stringify(config, null, 4));
|
||||
}
|
||||
|
||||
|
||||
return this.set(config);
|
||||
},
|
||||
get: function get() {
|
||||
if(!config) {
|
||||
if(Environment.isDebug)
|
||||
console.log("Oops.. trying to get config without config existing... Returning defaults... (Is the database still initialising?)");
|
||||
if (!config) {
|
||||
if (Environment.isDebug)
|
||||
console.log(
|
||||
"Oops.. trying to get config without config existing... Returning defaults... (Is the database still initialising?)"
|
||||
);
|
||||
return {};
|
||||
}
|
||||
return config;
|
||||
@@ -43,7 +45,7 @@ export const PluginConfig = {
|
||||
config = val.merge(config);
|
||||
|
||||
return applyConfig(config);
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
function applyConfig(val: any) {
|
||||
@@ -56,17 +58,14 @@ function applyConfig(val: any) {
|
||||
|
||||
pair.key = key;
|
||||
pair.value = obj;
|
||||
if(!pair.key || pair.key == null) {
|
||||
console.log(`[PluginConfig] WARN: Empty key`)
|
||||
if (!pair.key || pair.key == null) {
|
||||
console.log(`[PluginConfig] WARN: Empty key`);
|
||||
console.log(pair);
|
||||
if(Environment.isDebug) debugger;
|
||||
}
|
||||
else
|
||||
return pair.save();
|
||||
if (Environment.isDebug) debugger;
|
||||
} else return pair.save();
|
||||
}
|
||||
if(process.env.PLUGIN_CONFIG_PATH) {
|
||||
if(Environment.isDebug)
|
||||
console.log(`Writing config: ${process.env.PLUGIN_CONFIG_PATH}`)
|
||||
if (process.env.PLUGIN_CONFIG_PATH) {
|
||||
if (Environment.isDebug) console.log(`Writing config: ${process.env.PLUGIN_CONFIG_PATH}`);
|
||||
fs.writeFileSync(overridePath, JSON.stringify(val, null, 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +1,102 @@
|
||||
import { PreRegisterEventArgs, OnRegisterEventArgs, PreRegisterEventResult } from './event_types';
|
||||
import { PreMessageEventArgs, OnMessageEventArgs, PreMessageEventResult } from './event_types';
|
||||
import { PreLoginEventArgs, OnLoginEventArgs, PreLoginEventResult } from './event_types';
|
||||
import { PreGuildCreateEventArgs, OnGuildCreateEventArgs, PreGuildCreateEventResult } from './event_types';
|
||||
import { PreChannelCreateEventArgs, OnChannelCreateEventArgs, PreChannelCreateEventResult } from './event_types';
|
||||
import { PreTypingEventArgs, OnTypingEventArgs, PreTypingEventResult } from './event_types';
|
||||
import { PreStatusChangeEventArgs, OnStatusChangeEventArgs, PreStatusChangeEventResult } from './event_types';
|
||||
import { PluginStore } from ".";
|
||||
import {
|
||||
OnChannelCreateEventArgs,
|
||||
OnGuildCreateEventArgs,
|
||||
OnLoginEventArgs,
|
||||
OnMessageEventArgs,
|
||||
OnRegisterEventArgs,
|
||||
OnStatusChangeEventArgs,
|
||||
OnTypingEventArgs,
|
||||
PreChannelCreateEventArgs,
|
||||
PreChannelCreateEventResult,
|
||||
PreGuildCreateEventArgs,
|
||||
PreGuildCreateEventResult,
|
||||
PreLoginEventArgs,
|
||||
PreLoginEventResult,
|
||||
PreMessageEventArgs,
|
||||
PreMessageEventResult,
|
||||
PreRegisterEventArgs,
|
||||
PreRegisterEventResult,
|
||||
PreStatusChangeEventArgs,
|
||||
PreStatusChangeEventResult,
|
||||
PreTypingEventArgs,
|
||||
PreTypingEventResult
|
||||
} from "./event_types";
|
||||
|
||||
export class PluginEventHandler {
|
||||
public static async preRegisterEvent(args: PreRegisterEventArgs): Promise<PreRegisterEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreRegister).map(x=>x.onPreRegister && x.onPreRegister(args)))).filter(x=>x) as PreRegisterEventResult[];
|
||||
}
|
||||
|
||||
public static async onRegisterEvent(args: OnRegisterEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onRegister).map(x=>x.onRegister && x.onRegister(args)));
|
||||
}
|
||||
|
||||
public static async preMessageEvent(args: PreMessageEventArgs): Promise<PreMessageEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreMessage).map(x=>x.onPreMessage && x.onPreMessage(args)))).filter(x=>x) as PreMessageEventResult[];
|
||||
}
|
||||
|
||||
public static async onMessageEvent(args: OnMessageEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onMessage).map(x=>x.onMessage && x.onMessage(args)));
|
||||
}
|
||||
|
||||
public static async preLoginEvent(args: PreLoginEventArgs): Promise<PreLoginEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreLogin).map(x=>x.onPreLogin && x.onPreLogin(args)))).filter(x=>x) as PreLoginEventResult[];
|
||||
}
|
||||
|
||||
public static async onLoginEvent(args: OnLoginEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onLogin).map(x=>x.onLogin && x.onLogin(args)));
|
||||
}
|
||||
|
||||
public static async preGuildCreateEvent(args: PreGuildCreateEventArgs): Promise<PreGuildCreateEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreGuildCreate).map(x=>x.onPreGuildCreate && x.onPreGuildCreate(args)))).filter(x=>x) as PreGuildCreateEventResult[];
|
||||
}
|
||||
|
||||
public static async onGuildCreateEvent(args: OnGuildCreateEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onGuildCreate).map(x=>x.onGuildCreate && x.onGuildCreate(args)));
|
||||
}
|
||||
|
||||
public static async preChannelCreateEvent(args: PreChannelCreateEventArgs): Promise<PreChannelCreateEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreChannelCreate).map(x=>x.onPreChannelCreate && x.onPreChannelCreate(args)))).filter(x=>x) as PreChannelCreateEventResult[];
|
||||
}
|
||||
|
||||
public static async onChannelCreateEvent(args: OnChannelCreateEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onChannelCreate).map(x=>x.onChannelCreate && x.onChannelCreate(args)));
|
||||
}
|
||||
|
||||
public static async preTypingEvent(args: PreTypingEventArgs): Promise<PreTypingEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreTyping).map(x=>x.onPreTyping && x.onPreTyping(args)))).filter(x=>x) as PreTypingEventResult[];
|
||||
}
|
||||
|
||||
public static async onTypingEvent(args: OnTypingEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onTyping).map(x=>x.onTyping && x.onTyping(args)));
|
||||
}
|
||||
|
||||
public static async preStatusChangeEvent(args: PreStatusChangeEventArgs): Promise<PreStatusChangeEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter(x=>x.onPreStatusChange).map(x=>x.onPreStatusChange && x.onPreStatusChange(args)))).filter(x=>x) as PreStatusChangeEventResult[];
|
||||
}
|
||||
|
||||
public static async onStatusChangeEvent(args: OnStatusChangeEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter(x=>x.onStatusChange).map(x=>x.onStatusChange && x.onStatusChange(args)));
|
||||
}
|
||||
|
||||
public static async preRegisterEvent(args: PreRegisterEventArgs): Promise<PreRegisterEventResult[]> {
|
||||
return (
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onPreRegister).map((x) => x.onPreRegister && x.onPreRegister(args)))
|
||||
).filter((x) => x) as PreRegisterEventResult[];
|
||||
}
|
||||
|
||||
public static async onRegisterEvent(args: OnRegisterEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onRegister).map((x) => x.onRegister && x.onRegister(args)));
|
||||
}
|
||||
|
||||
public static async preMessageEvent(args: PreMessageEventArgs): Promise<PreMessageEventResult[]> {
|
||||
return (
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onPreMessage).map((x) => x.onPreMessage && x.onPreMessage(args)))
|
||||
).filter((x) => x) as PreMessageEventResult[];
|
||||
}
|
||||
|
||||
public static async onMessageEvent(args: OnMessageEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onMessage).map((x) => x.onMessage && x.onMessage(args)));
|
||||
}
|
||||
|
||||
public static async preLoginEvent(args: PreLoginEventArgs): Promise<PreLoginEventResult[]> {
|
||||
return (await Promise.all(PluginStore.plugins.filter((x) => x.onPreLogin).map((x) => x.onPreLogin && x.onPreLogin(args)))).filter(
|
||||
(x) => x
|
||||
) as PreLoginEventResult[];
|
||||
}
|
||||
|
||||
public static async onLoginEvent(args: OnLoginEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onLogin).map((x) => x.onLogin && x.onLogin(args)));
|
||||
}
|
||||
|
||||
public static async preGuildCreateEvent(args: PreGuildCreateEventArgs): Promise<PreGuildCreateEventResult[]> {
|
||||
return (
|
||||
await Promise.all(
|
||||
PluginStore.plugins.filter((x) => x.onPreGuildCreate).map((x) => x.onPreGuildCreate && x.onPreGuildCreate(args))
|
||||
)
|
||||
).filter((x) => x) as PreGuildCreateEventResult[];
|
||||
}
|
||||
|
||||
public static async onGuildCreateEvent(args: OnGuildCreateEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onGuildCreate).map((x) => x.onGuildCreate && x.onGuildCreate(args)));
|
||||
}
|
||||
|
||||
public static async preChannelCreateEvent(args: PreChannelCreateEventArgs): Promise<PreChannelCreateEventResult[]> {
|
||||
return (
|
||||
await Promise.all(
|
||||
PluginStore.plugins.filter((x) => x.onPreChannelCreate).map((x) => x.onPreChannelCreate && x.onPreChannelCreate(args))
|
||||
)
|
||||
).filter((x) => x) as PreChannelCreateEventResult[];
|
||||
}
|
||||
|
||||
public static async onChannelCreateEvent(args: OnChannelCreateEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onChannelCreate).map((x) => x.onChannelCreate && x.onChannelCreate(args)));
|
||||
}
|
||||
|
||||
public static async preTypingEvent(args: PreTypingEventArgs): Promise<PreTypingEventResult[]> {
|
||||
return (
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onPreTyping).map((x) => x.onPreTyping && x.onPreTyping(args)))
|
||||
).filter((x) => x) as PreTypingEventResult[];
|
||||
}
|
||||
|
||||
public static async onTypingEvent(args: OnTypingEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onTyping).map((x) => x.onTyping && x.onTyping(args)));
|
||||
}
|
||||
|
||||
public static async preStatusChangeEvent(args: PreStatusChangeEventArgs): Promise<PreStatusChangeEventResult[]> {
|
||||
return (
|
||||
await Promise.all(
|
||||
PluginStore.plugins.filter((x) => x.onPreStatusChange).map((x) => x.onPreStatusChange && x.onPreStatusChange(args))
|
||||
)
|
||||
).filter((x) => x) as PreStatusChangeEventResult[];
|
||||
}
|
||||
|
||||
public static async onStatusChangeEvent(args: OnStatusChangeEventArgs): Promise<void> {
|
||||
await Promise.all(PluginStore.plugins.filter((x) => x.onStatusChange).map((x) => x.onStatusChange && x.onStatusChange(args)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { Plugin, PluginLoadedEventArgs, PluginManifest, PluginStore } from "./";
|
||||
import { PluginIndex } from "plugins/PluginIndex";
|
||||
import path from "path";
|
||||
import { OrmUtils } from "..";
|
||||
import { PluginIndex } from "../../plugins/PluginIndex";
|
||||
import { PluginLoadedEventArgs, PluginManifest, PluginStore } from "./";
|
||||
import { PluginConfig } from "./PluginConfig";
|
||||
import { OrmUtils, PluginConfigEntity } from "..";
|
||||
|
||||
const root = process.env.PLUGIN_LOCATION || "dist/plugins";
|
||||
|
||||
let pluginsLoaded = false;
|
||||
export class PluginLoader {
|
||||
public static async loadPlugins() {
|
||||
if(pluginsLoaded) return;
|
||||
if (pluginsLoaded) return;
|
||||
PluginConfig.init();
|
||||
console.log(`Plugin root directory: ${path.resolve(root)}`);
|
||||
const dirs = fs.readdirSync(root).filter((x) => {
|
||||
@@ -33,33 +33,31 @@ export class PluginLoader {
|
||||
`Plugin info: ${manifest.name} (${manifest.id}), written by ${manifest.authors}, available at ${manifest.repository}`
|
||||
);
|
||||
const module_ = PluginIndex[manifest.id];
|
||||
|
||||
|
||||
module_.pluginPath = modPath;
|
||||
module_.pluginManifest = manifest;
|
||||
Object.freeze(module_.pluginPath);
|
||||
Object.freeze(module_.pluginManifest);
|
||||
|
||||
if(module_.onPluginLoaded) await module_.onPluginLoaded({} as PluginLoadedEventArgs);
|
||||
|
||||
if (module_.onPluginLoaded) await module_.onPluginLoaded({} as PluginLoadedEventArgs);
|
||||
PluginStore.plugins.push(module_);
|
||||
});
|
||||
|
||||
console.log(`Done loading ${PluginStore.plugins.length} plugins!`);
|
||||
}
|
||||
|
||||
|
||||
public static getPluginConfig(id: string, defaults?: any): any {
|
||||
let cfg = PluginConfig.get()[id];
|
||||
if(defaults) {
|
||||
if(cfg)
|
||||
cfg = OrmUtils.mergeDeep(defaults, cfg);
|
||||
else
|
||||
cfg = defaults;
|
||||
if (defaults) {
|
||||
if (cfg) cfg = OrmUtils.mergeDeep(defaults, cfg);
|
||||
else cfg = defaults;
|
||||
this.setPluginConfig(id, cfg);
|
||||
}
|
||||
if(!cfg) console.log(`[PluginConfig/WARN] Getting plugin settings for '${id}' returned null! (Did you forget to add settings?)`);
|
||||
if (!cfg) console.log(`[PluginConfig/WARN] Getting plugin settings for '${id}' returned null! (Did you forget to add settings?)`);
|
||||
return cfg;
|
||||
}
|
||||
public static async setPluginConfig(id: string, config: Partial<any>): Promise<void> {
|
||||
if(!config) console.log(`[PluginConfig/WARN] ${id} tried to set config=null!`);
|
||||
if (!config) console.log(`[PluginConfig/WARN] ${id} tried to set config=null!`);
|
||||
await PluginConfig.set({ [id]: OrmUtils.mergeDeep(PluginLoader.getPluginConfig(id) || {}, config) });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export class PluginManifest {
|
||||
id: string;
|
||||
name: string;
|
||||
authors: string[];
|
||||
repository: string;
|
||||
license: string;
|
||||
version: string // semver
|
||||
versionCode: number // integer
|
||||
mainClass: string;
|
||||
}
|
||||
id: string;
|
||||
name: string;
|
||||
authors: string[];
|
||||
repository: string;
|
||||
license: string;
|
||||
version: string; // semver
|
||||
versionCode: number; // integer
|
||||
mainClass: string;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import { Plugin, PluginLoadedEventArgs, PluginManifest } from "./";
|
||||
import { PluginIndex } from "plugins/PluginIndex";
|
||||
import { PluginConfig } from "./PluginConfig";
|
||||
import { OrmUtils, PluginConfigEntity } from "..";
|
||||
import { Plugin } from "./";
|
||||
|
||||
const root = process.env.PLUGIN_LOCATION || "dist/plugins";
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ import { Channel, Guild, User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreChannelCreateEventArgs {
|
||||
channel: Channel,
|
||||
guild: Guild,
|
||||
user: User
|
||||
channel: Channel;
|
||||
guild: Guild;
|
||||
user: User;
|
||||
}
|
||||
export interface PreChannelCreateEventResult extends EventResult {
|
||||
channel: Partial<Channel>
|
||||
channel: Partial<Channel>;
|
||||
}
|
||||
|
||||
export interface OnChannelCreateEventArgs {
|
||||
channel: Channel,
|
||||
guild: Guild,
|
||||
user: User
|
||||
channel: Channel;
|
||||
guild: Guild;
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Guild, User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreGuildCreateEventArgs {
|
||||
user: User,
|
||||
guild: Guild
|
||||
user: User;
|
||||
guild: Guild;
|
||||
}
|
||||
export interface PreGuildCreateEventResult extends EventResult {
|
||||
guild: Partial<Guild>
|
||||
guild: Partial<Guild>;
|
||||
}
|
||||
|
||||
export interface OnGuildCreateEventArgs {
|
||||
user: User,
|
||||
guild: Guild
|
||||
user: User;
|
||||
guild: Guild;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@ import { User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreLoginEventArgs {
|
||||
ip: String,
|
||||
user: User
|
||||
}
|
||||
export interface PreLoginEventResult extends EventResult {
|
||||
|
||||
ip: String;
|
||||
user: User;
|
||||
}
|
||||
export interface PreLoginEventResult extends EventResult {}
|
||||
|
||||
export interface OnLoginEventArgs {
|
||||
ip: String,
|
||||
user: User
|
||||
ip: String;
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Message, User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreMessageEventArgs {
|
||||
user: User,
|
||||
message: Message;
|
||||
user: User;
|
||||
message: Message;
|
||||
}
|
||||
export interface PreMessageEventResult extends EventResult {
|
||||
message: Partial<Message>
|
||||
message: Partial<Message>;
|
||||
}
|
||||
|
||||
export interface OnMessageEventArgs {
|
||||
user: User,
|
||||
message: Message
|
||||
user: User;
|
||||
message: Message;
|
||||
}
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
export interface PluginLoadedEventArgs {
|
||||
|
||||
}
|
||||
export interface PluginLoadedEventArgs {}
|
||||
|
||||
@@ -2,16 +2,16 @@ import { User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreRegisterEventArgs {
|
||||
age: any,
|
||||
user: User,
|
||||
ip: String
|
||||
age: any;
|
||||
user: User;
|
||||
ip: String;
|
||||
}
|
||||
export interface PreRegisterEventResult extends EventResult {
|
||||
user: Partial<User>
|
||||
user: Partial<User>;
|
||||
}
|
||||
|
||||
export interface OnRegisterEventArgs {
|
||||
age: any,
|
||||
user: User,
|
||||
ip: String
|
||||
age: any;
|
||||
user: User;
|
||||
ip: String;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ import { Presence } from "util/interfaces";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreStatusChangeEventArgs {
|
||||
user: User,
|
||||
presence: Presence
|
||||
user: User;
|
||||
presence: Presence;
|
||||
}
|
||||
export interface PreStatusChangeEventResult extends EventResult {
|
||||
presence: Partial<Presence>
|
||||
presence: Partial<Presence>;
|
||||
}
|
||||
|
||||
export interface OnStatusChangeEventArgs {
|
||||
user: User,
|
||||
presence: Presence
|
||||
user: User;
|
||||
presence: Presence;
|
||||
}
|
||||
|
||||
@@ -2,16 +2,14 @@ import { Channel, Guild, User } from "util/entities";
|
||||
import { EventResult } from ".";
|
||||
|
||||
export interface PreTypingEventArgs {
|
||||
channel: Channel,
|
||||
guild: Guild,
|
||||
user: User
|
||||
}
|
||||
export interface PreTypingEventResult extends EventResult {
|
||||
|
||||
channel: Channel;
|
||||
guild: Guild;
|
||||
user: User;
|
||||
}
|
||||
export interface PreTypingEventResult extends EventResult {}
|
||||
|
||||
export interface OnTypingEventArgs {
|
||||
channel: Channel,
|
||||
guild: Guild,
|
||||
user: User
|
||||
channel: Channel;
|
||||
guild: Guild;
|
||||
user: User;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ do
|
||||
echo " async onPre${event}?(args: Pre${event}EventArgs): Promise<Pre${event}EventResult>;"
|
||||
) >> ../plugin.eventfuncs.generated
|
||||
|
||||
echo "import { Pre${event}EventArgs, On${event}EventArgs, Pre${event}EventResult } from './event_types';" >> ../PluginEventHandler.ts.1
|
||||
echo "import { Pre${event}EventArgs, Pre${event}EventResult, On${event}EventArgs } from '.';" >> ../plugin.imports.generated
|
||||
echo "import { Pre${event}EventArgs, On${event}EventArgs, Pre${event}EventResult } from \"./event_types\";" >> ../PluginEventHandler.ts.1
|
||||
echo "import { Pre${event}EventArgs, Pre${event}EventResult, On${event}EventArgs } from \".\";" >> ../plugin.imports.generated
|
||||
cmp --silent "${event}EventArgs.ts" "${event}EventArgs.ts.generated" && rm -f "${event}EventArgs.ts.generated"
|
||||
done < _pdo
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface EventResult {
|
||||
cancel?: boolean;
|
||||
blockReason?: string;
|
||||
}
|
||||
cancel?: boolean;
|
||||
blockReason?: string;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./base/index";
|
||||
export * from "./ChannelCreateEventArgs";
|
||||
export * from "./GuildCreateEventArgs";
|
||||
export * from "./LoginEventArgs";
|
||||
@@ -6,4 +7,3 @@ export * from "./PluginLoadedEventArgs";
|
||||
export * from "./RegisterEventArgs";
|
||||
export * from "./StatusChangeEventArgs";
|
||||
export * from "./TypingEventArgs";
|
||||
export * from "./base/index";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export * from "./event_types/index";
|
||||
export * from "./Plugin";
|
||||
export * from "./PluginConfig";
|
||||
export * from "./PluginEventHandler";
|
||||
export * from "./PluginLoader";
|
||||
export * from "./PluginManifest";
|
||||
export * from "./PluginStore";
|
||||
export * from "./event_types/index";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Activity, Status } from "@fosscord/util";
|
||||
import { Activity, Status } from "..";
|
||||
|
||||
export const ActivitySchema = {
|
||||
afk: Boolean,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ChannelPermissionOverwrite } from "@fosscord/util";
|
||||
import { ChannelPermissionOverwrite } from "..";
|
||||
|
||||
// TODO: Only permissions your bot has in the guild or channel can be allowed/denied (unless your bot has a MANAGE_ROLES overwrite in the channel)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Embed } from "@fosscord/util";
|
||||
import { Embed } from "..";
|
||||
|
||||
export interface MessageCreateSchema {
|
||||
type?: number;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user