diff --git a/src/index.ts b/src/index.ts
index b218f8c2..8a434e46 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,14 +3,50 @@ import Config, { DefaultOptions } from "./util/Config";
import db from "./util/Database";
import * as Constants from "./util/Constants";
-import { Channel } from "./models/Channel";
+import {
+ Channel,
+ ChannelType,
+ DMChannel,
+ GuildChannel,
+ ReadState,
+ TextBasedChannel,
+ TextChannel,
+ VoiceChannel,
+} from "./models/Channel";
import { Emoji } from "./models/Emoji";
import { Guild } from "./models/Guild";
-import { Event } from "./models/Event";
import { Invite } from "./models/Invite";
-import { Member } from "./models/Member";
+import { Member, MuteConfig, PublicMember, UserGuildSettings } from "./models/Member";
import { Role } from "./models/Role";
-import { User } from "./models/User";
+import { User, ConnectedAccount, PublicUser, Relationship, UserSettings } from "./models/User";
+import { Activity, ActivityType, Presence } from "./models/Activity";
+import {
+ ApplicationCommand,
+ ApplicationCommandInteractionData,
+ ApplicationCommandInteractionDataOption,
+ ApplicationCommandOption,
+ ApplicationCommandOptionChoice,
+ ApplicationCommandOptionType,
+} from "./models/Application";
+import { ApplicationCommandPayload, EVENT, Event, MessagePayload } from "./models/Event";
+import {
+ Interaction,
+ InteractionApplicationCommandCallbackData,
+ InteractionResponseType,
+ InteractionType,
+} from "./models/Interaction";
+import {
+ AllowedMentions,
+ Attachment,
+ Embed,
+ EmbedImage,
+ Message,
+ MessageType,
+ PartialEmoji,
+ Reaction,
+} from "./models/Message";
+import { ClientStatus, Status } from "./models/Status";
+import { VoiceState } from "./models/VoiceState";
import { trimSpecial } from "./util/String";
import { BitField } from "./util/BitField";
@@ -26,19 +62,60 @@ export {
Config,
Constants,
db,
+ Activity,
+ ActivityType,
+ Presence,
BitField,
DefaultOptions,
Permissions,
- MessageFlags,
- UserFlags,
+ VoiceState,
Snowflake,
Intents,
Channel,
- Event,
+ ChannelType,
+ DMChannel,
+ GuildChannel,
+ ReadState,
+ TextBasedChannel,
+ TextChannel,
+ VoiceChannel,
Emoji,
Guild,
Invite,
Member,
+ ClientStatus,
+ Status,
+ MuteConfig,
+ PublicMember,
+ UserGuildSettings,
Role,
User,
+ UserFlags,
+ UserSettings,
+ ConnectedAccount,
+ PublicUser,
+ Relationship,
+ EVENT,
+ Event,
+ MessageType,
+ Message,
+ MessageFlags,
+ MessagePayload,
+ AllowedMentions,
+ Attachment,
+ Embed,
+ EmbedImage,
+ PartialEmoji,
+ Reaction,
+ Interaction,
+ InteractionApplicationCommandCallbackData,
+ InteractionResponseType,
+ InteractionType,
+ ApplicationCommand,
+ ApplicationCommandPayload,
+ ApplicationCommandInteractionData,
+ ApplicationCommandInteractionDataOption,
+ ApplicationCommandOption,
+ ApplicationCommandOptionChoice,
+ ApplicationCommandOptionType,
};
diff --git a/src/models/Activity.ts b/src/models/Activity.ts
new file mode 100644
index 00000000..d89a84a6
--- /dev/null
+++ b/src/models/Activity.ts
@@ -0,0 +1,54 @@
+import { User } from "..";
+import { ClientStatus, Status } from "./Status";
+
+export interface Presence {
+ user: User;
+ guild_id: bigint;
+ status: Status;
+ activities: Activity[];
+ client_status: ClientStatus;
+}
+
+export interface Activity {
+ name: string;
+ type: ActivityType;
+ url?: string;
+ created_at: number;
+ timestamps?: {
+ start: number;
+ end: number;
+ }[];
+ application_id?: bigint;
+ details?: string;
+ state?: string;
+ emoji?: {
+ name: string;
+ id?: bigint;
+ amimated?: boolean;
+ };
+ party?: {
+ id?: string;
+ size?: [number, number];
+ };
+ assets?: {
+ large_image: string;
+ large_text: string;
+ small_image: string;
+ small_text: string;
+ };
+ secrets?: {
+ join?: string;
+ spectate?: string;
+ match?: string;
+ };
+ instance?: boolean;
+ flags?: bigint;
+}
+
+export enum ActivityType {
+ GAME = 0,
+ STREAMING = 1,
+ LISTENING = 2,
+ CUSTOM = 4,
+ COMPETING = 5,
+}
diff --git a/src/models/Application.ts b/src/models/Application.ts
new file mode 100644
index 00000000..ea443dc9
--- /dev/null
+++ b/src/models/Application.ts
@@ -0,0 +1,44 @@
+export interface ApplicationCommand {
+ id: bigint;
+ application_id: bigint;
+ name: string;
+ description: string;
+ options?: ApplicationCommandOption[];
+}
+
+export interface ApplicationCommandOption {
+ type: ApplicationCommandOptionType;
+ name: string;
+ description: string;
+ required?: boolean;
+ choices?: ApplicationCommandOptionChoice[];
+ options?: ApplicationCommandOption[];
+}
+
+export interface ApplicationCommandOptionChoice {
+ name: string;
+ value: string | number;
+}
+
+export enum ApplicationCommandOptionType {
+ SUB_COMMAND = 1,
+ SUB_COMMAND_GROUP = 2,
+ STRING = 3,
+ INTEGER = 4,
+ BOOLEAN = 5,
+ USER = 6,
+ CHANNEL = 7,
+ ROLE = 8,
+}
+
+export interface ApplicationCommandInteractionData {
+ id: bigint;
+ name: string;
+ options?: ApplicationCommandInteractionDataOption[];
+}
+
+export interface ApplicationCommandInteractionDataOption {
+ name: string;
+ value?: any;
+ options?: ApplicationCommandInteractionDataOption[];
+}
diff --git a/src/models/Channel.ts b/src/models/Channel.ts
index 81fec185..068f6b67 100644
--- a/src/models/Channel.ts
+++ b/src/models/Channel.ts
@@ -1,15 +1,27 @@
export interface Channel {
id: bigint;
- guild_id: bigint;
- last_message_id: string;
- last_pin_timestamp: string;
+ created_at: number;
name: string;
- nsfw: boolean;
- parent_id: bigint;
- position: number;
- rate_limit_per_user: number;
- topic: string | null;
type: number;
+ read_state: ReadState[];
+}
+
+export interface ReadState {
+ last_message_id: bigint;
+ last_pin_timestamp: number;
+ mention_count: number;
+}
+
+export interface TextBasedChannel {
+ messages: any[];
+ last_message_id?: bigint;
+ last_pin_timestamp?: number;
+}
+
+export interface GuildChannel extends Channel {
+ guild_id: bigint;
+ position: number;
+ parent_id?: bigint;
permission_overwrites: {
allow: bigint;
deny: bigint;
@@ -17,3 +29,26 @@ export interface Channel {
type: number;
}[];
}
+
+export interface VoiceChannel extends GuildChannel {}
+
+export interface TextChannel extends GuildChannel, TextBasedChannel {
+ nsfw: boolean;
+ rate_limit_per_user: number;
+ topic?: string;
+}
+
+export interface DMChannel extends Channel, TextBasedChannel {
+ owner_id: bigint;
+ recipients: bigint[];
+}
+
+export enum ChannelType {
+ GUILD_TEXT = 0, // a text channel within a server
+ DM = 1, // a direct message between users
+ GUILD_VOICE = 2, // a voice channel within a server
+ GROUP_DM = 3, // a direct message between multiple users
+ GUILD_CATEGORY = 4, // an organizational category that contains up to 50 channels
+ GUILD_NEWS = 5, // a channel that users can follow and crosspost into their own server
+ GUILD_STORE = 6, // a channel in which game developers can sell their game on Discord
+}
diff --git a/src/models/Guild.ts b/src/models/Guild.ts
index 7e6fa614..7cf3b193 100644
--- a/src/models/Guild.ts
+++ b/src/models/Guild.ts
@@ -1,4 +1,4 @@
-import { Channel } from "./Channel";
+import { GuildChannel } from "./Channel";
import { Emoji } from "./Emoji";
import { Member } from "./Member";
import { Role } from "./Role";
@@ -8,13 +8,13 @@ export interface Guild {
afk_timeout?: number;
application_id?: bigint;
banner?: string;
- channels: Channel[];
+ channels: GuildChannel[];
default_message_notifications?: number;
description?: string;
discovery_splash?: string;
emojis: Emoji[];
explicit_content_filter?: number;
- features: [];
+ features: string[];
icon?: string;
id: bigint;
// joined_at?: number; \n // owner?: boolean; // ! member specific should be removed
diff --git a/src/models/Guild.ts.OLD b/src/models/Guild.ts.OLD
deleted file mode 100644
index 7f65ed17..00000000
--- a/src/models/Guild.ts.OLD
+++ /dev/null
@@ -1,37 +0,0 @@
-export interface Guild {
- id: bigint;
- name: string;
- icon: string; // e.g. "28776e7ad42922582be25bb06cdc5b53"
- 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
-}
diff --git a/src/models/Interaction.ts b/src/models/Interaction.ts
new file mode 100644
index 00000000..6f36c14a
--- /dev/null
+++ b/src/models/Interaction.ts
@@ -0,0 +1,32 @@
+import { AllowedMentions, Embed } from "./Message";
+
+export interface Interaction {
+ id: bigint;
+ type: InteractionType;
+ data?: {};
+ guild_id: bigint;
+ channel_id: bigint;
+ member_id: bigint;
+ token: string;
+ version: number;
+}
+
+export enum InteractionType {
+ Ping = 1,
+ ApplicationCommand = 2,
+}
+
+export enum InteractionResponseType {
+ Pong = 1,
+ Acknowledge = 2,
+ ChannelMessage = 3,
+ ChannelMessageWithSource = 4,
+ AcknowledgeWithSource = 5,
+}
+
+export interface InteractionApplicationCommandCallbackData {
+ tts?: boolean;
+ content: string;
+ embeds?: Embed[];
+ allowed_mentions?: AllowedMentions;
+}
diff --git a/src/models/Invite.ts b/src/models/Invite.ts
index 900eb4a1..df1286f5 100644
--- a/src/models/Invite.ts
+++ b/src/models/Invite.ts
@@ -1,5 +1,10 @@
export interface Invite {
code: string;
+ temporary: boolean;
+ uses: number;
+ max_uses: number;
+ max_age: number;
+ created_at: number;
guild: {
id: bigint;
name: string;
diff --git a/src/models/Member.ts b/src/models/Member.ts
index 8b63260a..a38a5ca3 100644
--- a/src/models/Member.ts
+++ b/src/models/Member.ts
@@ -1,3 +1,5 @@
+import { PublicUser } from "./User";
+
export interface Member {
id: bigint;
nick?: string;
@@ -8,4 +10,30 @@ export interface Member {
mute: boolean;
pending: boolean;
permissions: bigint;
+ settings: UserGuildSettings;
+}
+
+export interface PublicMember extends Omit<Member, "settings" | "id"> {
+ user: PublicUser;
+}
+
+export interface UserGuildSettings {
+ channel_overrides: {
+ channel_id: bigint;
+ message_notifications: number;
+ mute_config: MuteConfig;
+ muted: boolean;
+ }[];
+ message_notifications: number;
+ mobile_push: boolean;
+ mute_config: MuteConfig;
+ muted: boolean;
+ suppress_everyone: boolean;
+ suppress_roles: boolean;
+ version: number;
+}
+
+export interface MuteConfig {
+ end_time: number;
+ selected_time_window: number;
}
diff --git a/src/models/Message.ts b/src/models/Message.ts
new file mode 100644
index 00000000..45aefd34
--- /dev/null
+++ b/src/models/Message.ts
@@ -0,0 +1,126 @@
+import { ChannelType } from "./Channel";
+
+export interface Message {
+ id: bigint;
+ author_id?: bigint;
+ webhook_id?: bigint;
+ application_id: bigint;
+ content: string;
+ timestamp: number;
+ edited_timestamp: number;
+ tts: boolean;
+ mention_everyone: boolean;
+ mentions: bigint[];
+ mention_roles: bigint[];
+ mention_channels?: {
+ id: bigint;
+ guild_id: bigint;
+ type: ChannelType;
+ name: string;
+ }[];
+ attachments: Attachment[];
+ embeds: Embed[];
+ reactions?: Reaction[];
+ nonce?: string | number;
+ pinned: boolean;
+ type: MessageType;
+ activity?: {
+ type: number;
+ party_id: string;
+ }[];
+ flags?: bigint;
+ stickers?: [];
+ message_reference?: {
+ message_id: bigint;
+ channel_id?: bigint;
+ guild_id?: bigint;
+ };
+}
+
+export enum MessageType {
+ DEFAULT = 0,
+ RECIPIENT_ADD = 1,
+ RECIPIENT_REMOVE = 2,
+ CALL = 3,
+ CHANNEL_NAME_CHANGE = 4,
+ CHANNEL_ICON_CHANGE = 5,
+ CHANNEL_PINNED_MESSAGE = 6,
+ GUILD_MEMBER_JOIN = 7,
+ USER_PREMIUM_GUILD_SUBSCRIPTION = 8,
+ USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9,
+ USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10,
+ USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11,
+ CHANNEL_FOLLOW_ADD = 12,
+ GUILD_DISCOVERY_DISQUALIFIED = 14,
+ GUILD_DISCOVERY_REQUALIFIED = 15,
+ REPLY = 19,
+ APPLICATION_COMMAND = 20,
+}
+
+export interface Attachment {
+ id: bigint; // attachment id
+ filename: string; // name of file attached
+ size: number; // size of file in bytes
+ url: string; // source url of file
+ proxy_url: string; // a proxied url of file
+ height: number; // height of file (if image)
+ width: number; // width of file (if image)
+}
+
+export interface Embed {
+ title?: string; //title of embed
+ type?: string; // type of embed (always "rich" for webhook embeds)
+ description?: string; // description of embed
+ url?: string; // url of embed
+ timestamp?: number; // timestamp of embed content
+ color?: number; // color code of the embed
+ footer?: {
+ text: string;
+ icon_url?: string;
+ proxy_icon_url?: string;
+ }; // footer object footer information
+ image?: EmbedImage; // image object image information
+ thumbnail?: EmbedImage; // thumbnail object thumbnail information
+ video?: EmbedImage; // video object video information
+ provider?: {
+ name?: string;
+ url?: string;
+ }; // provider object provider information
+ author?: {
+ name?: string;
+ url?: string;
+ icon_url?: string;
+ proxy_icon_url?: string;
+ }; // author object author information
+ fields?: {
+ name: string;
+ value: string;
+ inline?: boolean;
+ }[];
+}
+
+export interface EmbedImage {
+ url?: string;
+ proxy_url?: string;
+ height?: number;
+ width?: number;
+}
+
+export interface Reaction {
+ count: number;
+ //// not saved in the database // me: boolean; // whether the current user reacted using this emoji
+ emoji: PartialEmoji;
+}
+
+export interface PartialEmoji {
+ id?: bigint;
+ name: string;
+ animated?: boolean;
+}
+
+export interface AllowedMentions {
+ parse?: ("users" | "roles" | "everyone")[];
+ roles?: bigint[];
+ users?: bigint[];
+ replied_user?: boolean;
+}
diff --git a/src/models/Status.ts b/src/models/Status.ts
new file mode 100644
index 00000000..c4dab586
--- /dev/null
+++ b/src/models/Status.ts
@@ -0,0 +1,7 @@
+export type Status = "idle" | "dnd" | "online" | "offline";
+
+export interface ClientStatus {
+ desktop?: string; // e.g. Windows/Linux/Mac
+ mobile?: string; // e.g. iOS/Android
+ web?: string; // e.g. browser, bot account
+}
diff --git a/src/models/User.ts b/src/models/User.ts
index 27e20e1c..36184ce6 100644
--- a/src/models/User.ts
+++ b/src/models/User.ts
@@ -1,21 +1,55 @@
-import { UserFlags } from "../util/UserFlags";
-
export interface User {
id: bigint;
username: string;
discriminator: string;
avatar: string | null;
+ phone?: string;
+ desktop: boolean;
+ mobile: boolean;
+ premium: boolean;
+ premium_type: number;
bot: boolean;
system: boolean;
+ nsfw_allowed: boolean;
mfa_enabled: boolean;
created_at: number;
verified: boolean;
email: string;
flags: bigint; // TODO: automatically convert BigInt to BitField of UserFlags
+ public_flags: bigint;
hash: string; // hash of the password, salt is saved in password (bcrypt)
+ guilds: bigint[]; // array of guild ids the user is part of
valid_tokens_since: number; // all tokens with a previous issue date are invalid
user_settings: UserSettings;
- guilds: bigint[] // array of guild ids the user is part of
+ relationships: Relationship[];
+ connected_accounts: ConnectedAccount[];
+}
+
+export interface PublicUser {
+ id: bigint;
+ discriminator: string;
+ username: string;
+ avatar?: string;
+ publicFlags: bigint;
+}
+
+export interface ConnectedAccount {
+ access_token: string;
+ friend_sync: boolean;
+ id: string;
+ name: string;
+ revoked: boolean;
+ show_activity: boolean;
+ type: string;
+ verifie: boolean;
+ visibility: number;
+}
+
+export interface Relationship {
+ id: bigint;
+ nickname?: string;
+ type: number;
+ user_id: bigint;
}
export interface UserSettings {
diff --git a/src/models/VoiceState.ts b/src/models/VoiceState.ts
new file mode 100644
index 00000000..19a1bf27
--- /dev/null
+++ b/src/models/VoiceState.ts
@@ -0,0 +1,15 @@
+import { PublicMember } from "./Member";
+
+export interface VoiceState {
+ guild_id?: bigint;
+ channel_id: bigint;
+ user_id: bigint;
+ session_id: string;
+ deaf: boolean;
+ mute: boolean;
+ self_deaf: boolean;
+ self_mute: boolean;
+ self_stream?: boolean;
+ self_video: boolean;
+ suppress: boolean; // whether this user is muted by the current user
+}
|