summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 20:59:58 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 20:59:58 +0100
commit3d54ed476240702812caf0b6e1ce94bfb0329cb5 (patch)
tree9f928dee5023de75b22d6b99c25c3c3fd967da7f /src
parentexport event (diff)
downloadserver-3d54ed476240702812caf0b6e1ce94bfb0329cb5.tar.xz
fix models + move schemas in api and gateway
Diffstat (limited to 'src')
-rw-r--r--src/Schema/Activity.ts81
-rw-r--r--src/Schema/Emoji.ts11
-rw-r--r--src/Schema/Guild.ts35
-rw-r--r--src/Schema/Identify.ts33
-rw-r--r--src/index.ts10
-rw-r--r--src/models/Event.ts1
-rw-r--r--src/models/Guild.ts4
-rw-r--r--src/models/Role.ts4
8 files changed, 6 insertions, 173 deletions
diff --git a/src/Schema/Activity.ts b/src/Schema/Activity.ts
deleted file mode 100644

index 00772743..00000000 --- a/src/Schema/Activity.ts +++ /dev/null
@@ -1,81 +0,0 @@ -import { EmojiSchema } from "./Emoji"; - -export const ActivitySchema = { - afk: Boolean, - status: String, - $activities: [ - { - name: String, // the activity's name - type: Number, // activity type // TODO: check if its between range 0-5 - $url: String, // stream url, is validated when type is 1 - $created_at: Number, // unix timestamp of when the activity was added to the user's session - $timestamps: { - // unix timestamps for start and/or end of the game - start: Number, - end: Number, - }, - $application_id: BigInt, // application id for the game - $details: String, - $State: String, - $emoji: EmojiSchema, - $party: { - $id: String, - $size: [Number], // used to show the party's current and maximum size // TODO: array length 2 - }, - $assets: { - $large_image: String, // the id for a large asset of the activity, usually a snowflake - $large_text: String, // text displayed when hovering over the large image of the activity - $small_image: String, // the id for a small asset of the activity, usually a snowflake - $small_text: String, // text displayed when hovering over the small image of the activity - }, - $secrets: { - $join: String, // the secret for joining a party - $spectate: String, // the secret for spectating a game - $match: String, // the secret for a specific instanced match - }, - $instance: Boolean, - flags: BigInt, // activity flags OR d together, describes what the payload includes - }, - ], - $since: Number, // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -}; - -export interface ActivitySchema { - afk: boolean; - status: string; - activities?: [ - { - name: string; // the activity's name - type: number; // activity type // TODO: check if its between range 0-5 - url?: string; // stream url, is validated when type is 1 - created_at?: number; // unix timestamp of when the activity was added to the user's session - timestamps?: { - // unix timestamps for start and/or end of the game - start: number; - end: number; - }; - application_id?: bigint; // application id for the game - details?: string; - State?: string; - emoji?: EmojiSchema; - party?: { - id?: string; - size?: [number]; // used to show the party's current and maximum size // TODO: array length 2 - }; - assets?: { - large_image?: string; // the id for a large asset of the activity, usually a snowflake - large_text?: string; // text displayed when hovering over the large image of the activity - small_image?: string; // the id for a small asset of the activity, usually a snowflake - small_text?: string; // text displayed when hovering over the small image of the activity - }; - secrets?: { - join?: string; // the secret for joining a party - spectate?: string; // the secret for spectating a game - match?: string; // the secret for a specific instanced match - }; - instance?: boolean; - flags: bigint; // activity flags OR d together, describes what the payload includes - } - ]; - since?: number; // unix time (in milliseconds) of when the client went idle, or null if the client is not idle -} diff --git a/src/Schema/Emoji.ts b/src/Schema/Emoji.ts deleted file mode 100644
index 09f3ebb1..00000000 --- a/src/Schema/Emoji.ts +++ /dev/null
@@ -1,11 +0,0 @@ -export const EmojiSchema = { - name: String, // the name of the emoji - $id: BigInt, // the id of the emoji - animated: Boolean, // whether this emoji is animated -}; - -export interface EmojiSchema { - name: string; - id?: bigint; - animated: Boolean; -} diff --git a/src/Schema/Guild.ts b/src/Schema/Guild.ts deleted file mode 100644
index c8634362..00000000 --- a/src/Schema/Guild.ts +++ /dev/null
@@ -1,35 +0,0 @@ -export const GuildSchema = { - name: String, // ! 2-100 chars - $region: String, // ? voice region ? - // $icon: String, // TODO: add icon data (base64 128x128) - - // * --- useless for us due to templates being a thing --- * // - // $verification_level: Number, // ! https://discord.com/developers/docs/resources/guild#guild-object-verification-level - // $default_message_notifications: Number, // ! https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level - // $explicit_content_filter: Number, - // $roles: array of role objects, - // $channels: array of partial channel objects, - // $afk_channel_id: snowflake, - // * --- useless for us --- * // - - // $afk_timeout: Number, - // $system_channel_id: snowflake, -}; - -export interface GuildSchema { - name: string; // ! 2-100 chars - region?: string; // ? voice region ? - // icon?: string; // TODO: add icon data (base64 128x128) - - // * --- useless for us due to templates being a thing --- * // - // verification_level?: number; // ! https://discord.com/developers/docs/resources/guild#guild-object-verification-level - // default_message_notifications?: number; // ! https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level - // explicit_content_filter?: number; - // $roles: array of role objects, - // $channels: array of partial channel objects, - // $afk_channel_id: snowflake, - // * --- useless for us --- * // - - // afk_timeout?: number; - // system_channel_id?: snowflake, -} diff --git a/src/Schema/Identify.ts b/src/Schema/Identify.ts deleted file mode 100644
index cfc3702a..00000000 --- a/src/Schema/Identify.ts +++ /dev/null
@@ -1,33 +0,0 @@ -import { ActivitySchema } from "./Activity"; - -export const IdentifySchema = { - token: String, - intents: BigInt, // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - $properties: { - // bruh discord really uses $ in the property key, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - $$os: String, - $$browser: String, - $$device: String, - }, - $presence: ActivitySchema, - $compress: Boolean, - $large_threshold: Number, - $shard: [Number], - $guild_subscriptions: Boolean, -}; - -export interface IdentifySchema { - token: string; - properties: { - // bruh discord really uses $ in the property key, so we need to double prefix it, because instanceOf treats $ (prefix) as a optional key - $$os: string; - $$browser: string; - $$device: string; - }; - intents: bigint; // discord uses a Integer for bitfields we use bigints tho. | instanceOf will automatically convert the Number to a BigInt - presence?: ActivitySchema; - compress?: boolean; - large_threshold?: number; - shard?: [number]; - guild_subscriptions?: boolean; -} diff --git a/src/index.ts b/src/index.ts
index d18dfeac..b218f8c2 100644 --- a/src/index.ts +++ b/src/index.ts
@@ -12,12 +12,6 @@ import { Member } from "./models/Member"; import { Role } from "./models/Role"; import { User } from "./models/User"; -//* schema -import { EmojiSchema } from "./Schema/Emoji"; -import { ActivitySchema } from "./Schema/Activity"; -import { IdentifySchema } from "./Schema/Identify"; -import { GuildSchema } from "./Schema/Guild"; - import { trimSpecial } from "./util/String"; import { BitField } from "./util/BitField"; import { Intents } from "./util/Intents"; @@ -47,8 +41,4 @@ export { Member, Role, User, - EmojiSchema, - ActivitySchema, - IdentifySchema, - GuildSchema, }; diff --git a/src/models/Event.ts b/src/models/Event.ts
index 4197ed04..8b19fc13 100644 --- a/src/models/Event.ts +++ b/src/models/Event.ts
@@ -1,6 +1,7 @@ export interface Event { guild_id?: bigint; user_id?: bigint; + channel_id?: bigint; created_at: number; data: any; event: string; diff --git a/src/models/Guild.ts b/src/models/Guild.ts
index 33ec9587..7e6fa614 100644 --- a/src/models/Guild.ts +++ b/src/models/Guild.ts
@@ -7,8 +7,6 @@ export interface Guild { afk_channel_id?: bigint; afk_timeout?: number; application_id?: bigint; - approximate_member_count?: number; - approximate_presence_count?: number; banner?: string; channels: Channel[]; default_message_notifications?: number; @@ -25,11 +23,11 @@ export interface Guild { max_presences?: number; max_video_channel_users?: number; // ? default: 25, is this max 25 streaming or watching member_count?: number; + presence_count?: number; // users online members?: Member[]; mfa_level?: number; name: string; owner_id: bigint; - permissions?: string; preferred_locale?: string; // only community guilds can choose this premium_subscription_count?: number; premium_tier?: number; // nitro boost level diff --git a/src/models/Role.ts b/src/models/Role.ts
index 44ddfea1..e0f2f863 100644 --- a/src/models/Role.ts +++ b/src/models/Role.ts
@@ -1,4 +1,5 @@ export interface Role { + id: bigint; color: number; hoist: boolean; managed: boolean; @@ -6,4 +7,7 @@ export interface Role { name: string; permissions: bigint; position: number; + tags?: { + bot_id?: bigint; + }; }