Move Models/Schemas to server-util
This commit is contained in:
parent
7e3d6d1d9d
commit
9b7f4e2b66
1
.gitignore
vendored
1
.gitignore
vendored
@ -101,3 +101,4 @@ typings/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
.DS_Store
|
||||
|
3
dist/index.d.ts
vendored
3
dist/index.d.ts
vendored
@ -1,5 +1,6 @@
|
||||
import { checkToken } from "./checkToken";
|
||||
import Config, { DefaultOptions } from "./Config";
|
||||
import db from "./Database";
|
||||
import { db } from "discord-server-util";
|
||||
|
||||
import * as Constants from "./Constants";
|
||||
export { checkToken, Config, Constants, db, DefaultOptions };
|
||||
|
41
src/Schema/Activity.ts
Normal file
41
src/Schema/Activity.ts
Normal file
@ -0,0 +1,41 @@
|
||||
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
|
||||
};
|
5
src/Schema/Emoji.ts
Normal file
5
src/Schema/Emoji.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export const EmojiSchema = {
|
||||
name: String, // the name of the emoji
|
||||
id: BigInt, // the id of the emoji
|
||||
animated: Boolean, // whether this emoji is animated
|
||||
};
|
17
src/Schema/Identify.ts
Normal file
17
src/Schema/Identify.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { ActivitySchema } from "./Activity";
|
||||
|
||||
export const 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,
|
||||
};
|
@ -2,5 +2,12 @@ import { checkToken } from "./checkToken";
|
||||
import Config, { DefaultOptions } from "./Config";
|
||||
import db from "./Database";
|
||||
import * as Constants from "./Constants";
|
||||
import { Channel } from "./models/Channel";
|
||||
import { Emoji } from "./models/Emoji";
|
||||
import { Guild } from "./models/Guild";
|
||||
import { Invite } from "./models/Invite";
|
||||
import { Member } from "./models/Member";
|
||||
import { Role } from "./models/Role";
|
||||
import { User } from "./models/User";
|
||||
|
||||
export { checkToken, Config, Constants, db, DefaultOptions };
|
||||
export { checkToken, Config, Constants, db, DefaultOptions, Channel, Emoji, Guild, Invite, Member, Role, User };
|
||||
|
19
src/models/Channel.ts
Normal file
19
src/models/Channel.ts
Normal file
@ -0,0 +1,19 @@
|
||||
export interface Channel {
|
||||
id: bigint;
|
||||
guild_id: bigint;
|
||||
last_message_id: string;
|
||||
last_pin_timestamp: string;
|
||||
name: string;
|
||||
nsfw: boolean;
|
||||
parent_id: bigint;
|
||||
position: number;
|
||||
rate_limit_per_user: number;
|
||||
topic: string | null;
|
||||
type: number;
|
||||
permission_overwrites: {
|
||||
allow: bigint;
|
||||
deny: bigint;
|
||||
id: bigint;
|
||||
type: number;
|
||||
}[];
|
||||
}
|
12
src/models/Emoji.ts
Normal file
12
src/models/Emoji.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export interface Emoji {
|
||||
allNamesString: string; // e.g. :thonk:
|
||||
animated: boolean;
|
||||
available: boolean;
|
||||
guildId: bigint;
|
||||
id: bigint;
|
||||
managed: boolean;
|
||||
name: string;
|
||||
require_colons: boolean;
|
||||
url: string;
|
||||
roles: [];
|
||||
}
|
53
src/models/Guild.ts
Normal file
53
src/models/Guild.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { Channel } from "./Channel";
|
||||
import { Emoji } from "./Emoji";
|
||||
import { Member } from "./Member";
|
||||
import { Role } from "./Role";
|
||||
|
||||
export interface Guild {
|
||||
id: bigint;
|
||||
name: string;
|
||||
icon: string;
|
||||
icon_hash: string;
|
||||
splash: string;
|
||||
discovery_splash: string;
|
||||
owner: boolean;
|
||||
owner_id: bigint;
|
||||
permissions: string;
|
||||
region: string;
|
||||
afk_channel_id: bigint;
|
||||
afk_timeout: number;
|
||||
widget_enabled: boolean;
|
||||
widget_channel_id: bigint;
|
||||
verification_level: number;
|
||||
default_message_notifications: number;
|
||||
explicit_content_filter: number;
|
||||
roles: Role[];
|
||||
emojis: Emoji[];
|
||||
features: [];
|
||||
mfa_level: number;
|
||||
application_id: bigint;
|
||||
system_channel_id: bigint;
|
||||
system_channel_flags: number;
|
||||
rules_channel_id: bigint;
|
||||
joined_at: number;
|
||||
large: boolean;
|
||||
unavailable: boolean;
|
||||
member_count: number;
|
||||
voice_states: []; // ! tf is this
|
||||
members: Member[];
|
||||
channels: Channel[];
|
||||
presences: []; // TODO: add model
|
||||
max_presences: number;
|
||||
max_members: number;
|
||||
vanity_url_code: string;
|
||||
description: string;
|
||||
banner: string;
|
||||
premium_tier: number;
|
||||
premium_subscription_count: number;
|
||||
preferred_locale: string;
|
||||
public_updates_channel_id: bigint;
|
||||
max_video_channel_users: number;
|
||||
approximate_member_count: number;
|
||||
approximate_presence_count: number;
|
||||
welcome_screen: []; // ! what is this
|
||||
}
|
38
src/models/Guild.ts.OLD
Normal file
38
src/models/Guild.ts.OLD
Normal file
@ -0,0 +1,38 @@
|
||||
export interface Guild {
|
||||
id: bigint;
|
||||
name: string;
|
||||
icon: string; // e.g. "28776e7ad42922582be25bb06cdc5b53"
|
||||
icon_hash: string;
|
||||
afk_channel_id: bigint;
|
||||
afk_timeout: number;
|
||||
application_id: bigint;
|
||||
banner: string; // id
|
||||
description: string;
|
||||
explicit_content_filter: number;
|
||||
features: string[];
|
||||
/* guild_hashes: // ? what is this
|
||||
channels: {hash: "uZsNP+TWAFY", omitted: false}
|
||||
metadata: {hash: "JCboqYj68bQ", omitted: false}
|
||||
roles: {hash: "1d7EJBRgVqg", omitted: false}
|
||||
version: 1
|
||||
*/
|
||||
joined_at: string; // user specific, Date Iso: "2021-01-23T19:01:23.126002+00:00"
|
||||
large: boolean;
|
||||
lazy: boolean; // ? what is this
|
||||
max_members: number; // e.g. default 100.000
|
||||
max_video_channel_users: number; // ? default: 25, is this max 25 streaming or watching
|
||||
member_count: number; // current member count
|
||||
mfa_level: number;
|
||||
owner_id: bigint;
|
||||
preferred_locale: string; // only partnered/verified guilds can choose this
|
||||
premium_subscription_count: number; // number of boosts
|
||||
premium_tier: number; // ? what is this
|
||||
public_updates_channel_id: bigint; //
|
||||
rules_channel_id: bigint;
|
||||
splash: string; // e.g. "32bec3d01f1dc90933cbb0bd75d333b0"
|
||||
system_channel_flags: number;
|
||||
system_channel_id: bigint;
|
||||
vanity_url_code: string;
|
||||
verification_level: number;
|
||||
threads: []; // ? not yet finished
|
||||
}
|
31
src/models/Invite.ts
Normal file
31
src/models/Invite.ts
Normal file
@ -0,0 +1,31 @@
|
||||
export interface Invite {
|
||||
code: string;
|
||||
guild: {
|
||||
id: bigint;
|
||||
name: string;
|
||||
splash: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
features: Object;
|
||||
verification_level: number;
|
||||
};
|
||||
channel: {
|
||||
id: bigint;
|
||||
name: string;
|
||||
type: number;
|
||||
};
|
||||
|
||||
inviter: {
|
||||
id: bigint;
|
||||
username: string;
|
||||
avatar: string;
|
||||
discriminator: number;
|
||||
};
|
||||
target_user: {
|
||||
id: bigint;
|
||||
username: string;
|
||||
avatar: string;
|
||||
discriminator: number;
|
||||
};
|
||||
target_user_type: number;
|
||||
}
|
14
src/models/Member.ts
Normal file
14
src/models/Member.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Role } from "./Role";
|
||||
import { User } from "./User";
|
||||
|
||||
export interface Member {
|
||||
user: User;
|
||||
nick: string;
|
||||
roles: Role[];
|
||||
joined_at: number;
|
||||
premium_since: number;
|
||||
deaf: boolean;
|
||||
mute: boolean;
|
||||
pending: boolean;
|
||||
permissions: string;
|
||||
}
|
9
src/models/Role.ts
Normal file
9
src/models/Role.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface Role {
|
||||
color: number;
|
||||
hoist: boolean;
|
||||
managed: boolean;
|
||||
mentionable: boolean;
|
||||
name: string;
|
||||
permissions: bigint;
|
||||
position: number;
|
||||
}
|
62
src/models/User.ts
Normal file
62
src/models/User.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import { UserFlags } from "../util/UserFlags";
|
||||
|
||||
export interface User {
|
||||
id: bigint;
|
||||
username: string;
|
||||
discriminator: string;
|
||||
avatar: string | null;
|
||||
bot: boolean;
|
||||
system: boolean;
|
||||
mfa_enabled: boolean;
|
||||
created_at: number;
|
||||
verified: boolean;
|
||||
email: string;
|
||||
flags: bigint; // TODO: automatically convert BigInt to BitField of UserFlags
|
||||
hash: string; // hash of the password, salt is saved in password (bcrypt)
|
||||
valid_tokens_since: number; // all tokens with a previous issue date are invalid
|
||||
user_settings: UserSettings;
|
||||
}
|
||||
|
||||
export interface UserSettings {
|
||||
afk_timeout: number;
|
||||
allow_accessibility_detection: boolean;
|
||||
animate_emoji: boolean;
|
||||
animate_stickers: number;
|
||||
contact_sync_enabled: boolean;
|
||||
convert_emoticons: boolean;
|
||||
custom_status: {
|
||||
emoji_id: bigint | null;
|
||||
emoji_name: string | null;
|
||||
expires_at: number | null;
|
||||
text: string | null;
|
||||
};
|
||||
default_guilds_restricted: boolean;
|
||||
detect_platform_accounts: boolean;
|
||||
developer_mode: boolean;
|
||||
disable_games_tab: boolean;
|
||||
enable_tts_command: boolean;
|
||||
explicit_content_filter: number;
|
||||
friend_source_flags: { all: boolean };
|
||||
gif_auto_play: boolean;
|
||||
guild_folders: // every top guild is displayed as a "folder"
|
||||
{
|
||||
color: number;
|
||||
guild_ids: bigint[];
|
||||
id: number;
|
||||
name: string;
|
||||
}[];
|
||||
guild_positions: bigint[]; // guild ids ordered by position
|
||||
inline_attachment_media: boolean;
|
||||
inline_embed_media: boolean;
|
||||
locale: string; // en_US
|
||||
message_display_compact: boolean;
|
||||
native_phone_integration_enabled: boolean;
|
||||
render_embeds: boolean;
|
||||
render_reactions: boolean;
|
||||
restricted_guilds: bigint[];
|
||||
show_current_game: boolean;
|
||||
status: "online" | "offline" | "dnd" | "idle";
|
||||
stream_notifications_enabled: boolean;
|
||||
theme: "dark" | "white"; // dark
|
||||
timezone_offset: number; // e.g -60
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user