diff --git a/src/api/routes/channels/#channel_id/permissions.ts b/src/api/routes/channels/#channel_id/permissions.ts
index 89be843f..0a816223 100644
--- a/src/api/routes/channels/#channel_id/permissions.ts
+++ b/src/api/routes/channels/#channel_id/permissions.ts
@@ -1,12 +1,11 @@
import {
Channel,
ChannelPermissionOverwrite,
- ChannelPermissionOverwriteType,
ChannelUpdateEvent,
emitEvent,
- getPermission,
Member,
Role,
+ ChannelPermissionOverwriteSchema
} from "@fosscord/util";
import { Router, Response, Request } from "express";
import { HTTPError } from "lambert-server";
@@ -16,9 +15,6 @@ const router: Router = Router();
// 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)
-export interface ChannelPermissionOverwriteSchema
- extends ChannelPermissionOverwrite {}
-
router.put(
"/:overwrite_id",
route({
diff --git a/src/api/routes/guilds/#guild_id/index.ts b/src/api/routes/guilds/#guild_id/index.ts
index 715a3835..04cb76c2 100644
--- a/src/api/routes/guilds/#guild_id/index.ts
+++ b/src/api/routes/guilds/#guild_id/index.ts
@@ -8,29 +8,13 @@ import {
GuildUpdateEvent,
handleFile,
Member,
- GuildCreateSchema,
+ GuildUpdateSchema,
} from "@fosscord/util";
import { HTTPError } from "lambert-server";
import { route } from "@fosscord/api";
const router = Router();
-export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels"> {
- banner?: string | null;
- splash?: string | null;
- description?: string;
- features?: string[];
- verification_level?: number;
- default_message_notifications?: number;
- system_channel_flags?: number;
- explicit_content_filter?: number;
- public_updates_channel_id?: string;
- afk_timeout?: number;
- afk_channel_id?: string;
- preferred_locale?: string;
- premium_progress_bar_enabled?: boolean;
-}
-
router.get("/", route({}), async (req: Request, res: Response) => {
const { guild_id } = req.params;
diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts
index 30e5969c..4493fcc7 100644
--- a/src/api/routes/users/@me/settings.ts
+++ b/src/api/routes/users/@me/settings.ts
@@ -4,8 +4,6 @@ import { route } from "@fosscord/api";
const router = Router();
-export interface UserSettingsSchema extends Partial<UserSettings> {}
-
router.get("/", route({}), async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts
index e8cbe964..07a4e2a9 100644
--- a/src/gateway/events/Message.ts
+++ b/src/gateway/events/Message.ts
@@ -1,23 +1,16 @@
-import { CLOSECODES, OPCODES } from "../util/Constants";
-import { WebSocket, Payload } from "@fosscord/gateway";
-var erlpack: any;
-try {
- erlpack = require("@yukikaze-bot/erlpack");
-} catch (error) {}
+import { WebSocket, Payload, CLOSECODES, OPCODES } from "@fosscord/gateway";
import OPCodeHandlers from "../opcodes";
-import { Tuple } from "lambert-server";
import { check } from "../opcodes/instanceOf";
import WS from "ws";
-import BigIntJson from "json-bigint";
+import { PayloadSchema } from "@fosscord/util";
import * as Sentry from "@sentry/node";
+import BigIntJson from "json-bigint";
const bigIntJson = BigIntJson({ storeAsString: true });
-const PayloadSchema = {
- op: Number,
- $d: new Tuple(Object, Number), // or number for heartbeat sequence
- $s: Number,
- $t: String,
-};
+var erlpack: any;
+try {
+ erlpack = require("@yukikaze-bot/erlpack");
+} catch (error) { }
export async function Message(this: WebSocket, buffer: WS.Data) {
// TODO: compression
diff --git a/src/util/schemas/ChannelPermissionOverwriteSchema.ts b/src/util/schemas/ChannelPermissionOverwriteSchema.ts
new file mode 100644
index 00000000..6d6d6c34
--- /dev/null
+++ b/src/util/schemas/ChannelPermissionOverwriteSchema.ts
@@ -0,0 +1,4 @@
+import { ChannelPermissionOverwrite } from "@fosscord/util";
+
+export interface ChannelPermissionOverwriteSchema
+ extends ChannelPermissionOverwrite {}
\ No newline at end of file
diff --git a/src/util/schemas/GatewayPayloadSchema.ts b/src/util/schemas/GatewayPayloadSchema.ts
new file mode 100644
index 00000000..324ad1eb
--- /dev/null
+++ b/src/util/schemas/GatewayPayloadSchema.ts
@@ -0,0 +1,8 @@
+import { Tuple } from "lambert-server";
+
+export const PayloadSchema = {
+ op: Number,
+ $d: new Tuple(Object, Number), // or number for heartbeat sequence
+ $s: Number,
+ $t: String,
+};
\ No newline at end of file
diff --git a/src/util/schemas/GuildUpdateSchema.ts b/src/util/schemas/GuildUpdateSchema.ts
new file mode 100644
index 00000000..fb2ac4f2
--- /dev/null
+++ b/src/util/schemas/GuildUpdateSchema.ts
@@ -0,0 +1,17 @@
+import { GuildCreateSchema } from "@fosscord/util";
+
+export interface GuildUpdateSchema extends Omit<GuildCreateSchema, "channels"> {
+ banner?: string | null;
+ splash?: string | null;
+ description?: string;
+ features?: string[];
+ verification_level?: number;
+ default_message_notifications?: number;
+ system_channel_flags?: number;
+ explicit_content_filter?: number;
+ public_updates_channel_id?: string;
+ afk_timeout?: number;
+ afk_channel_id?: string;
+ preferred_locale?: string;
+ premium_progress_bar_enabled?: boolean;
+}
diff --git a/src/util/schemas/UserGuildSettingsSchema.ts b/src/util/schemas/UserGuildSettingsSchema.ts
new file mode 100644
index 00000000..43028c58
--- /dev/null
+++ b/src/util/schemas/UserGuildSettingsSchema.ts
@@ -0,0 +1,9 @@
+import { UserGuildSettings, ChannelOverride } from "@fosscord/util";
+
+// This sucks. I would use a DeepPartial, my own or typeorms, but they both generate inncorect schema
+export interface UserGuildSettingsSchema
+ extends Partial<Omit<UserGuildSettings, "channel_overrides">> {
+ channel_overrides: {
+ [channel_id: string]: Partial<ChannelOverride>;
+ };
+}
\ No newline at end of file
diff --git a/src/util/schemas/UserSettingsSchema.ts b/src/util/schemas/UserSettingsSchema.ts
new file mode 100644
index 00000000..db015457
--- /dev/null
+++ b/src/util/schemas/UserSettingsSchema.ts
@@ -0,0 +1,3 @@
+import { UserSettings } from "@fosscord/util";
+
+export interface UserSettingsSchema extends Partial<UserSettings> {}
\ No newline at end of file
diff --git a/src/util/schemas/index.ts b/src/util/schemas/index.ts
index ae80de71..ba9e71e4 100644
--- a/src/util/schemas/index.ts
+++ b/src/util/schemas/index.ts
@@ -39,3 +39,7 @@ export * from "./VoiceVideoSchema";
export * from "./IdentifySchema";
export * from "./ActivitySchema";
export * from "./LazyRequestSchema";
+export * from "./GuildUpdateSchema";
+export * from "./ChannelPermissionOverwriteSchema";
+export * from "./UserGuildSettingsSchema";
+export * from "./GatewayPayloadSchema"
\ No newline at end of file
|