diff --git a/.gitignore b/.gitignore index 360ea127..3af3a3cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ .vs +node_modules +package-lock.json \ No newline at end of file diff --git a/README.md b/README.md index c76d8f14..ba9e9487 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ A small, single-file, fully featured [Discordapp](https://discordapp.com) librar **[Stable](https://www.npmjs.com/package/discord.io)** `npm install discord.io` -**[Latest](https://github.com/izy521/discord.io)** -`npm install izy521/discord.io` +**[Latest](https://github.com/jsrobson10/discord.io)** +`npm install jsrobson10/discord.io` #### Example ```javascript diff --git a/typings/index.d.ts b/typings/index.d.ts index 5ba4a278..db1177ef 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3,12 +3,81 @@ */ declare type region = "brazil" | "frankfurt" | "amsterdam" | "london" | "singapore" | "us-east" | "us-central" | "us-south" | "us-west" | "sydney"; -declare type userStatus = "online" | "idle" | "offline"; +declare type userStatus = "online" | "idle" | "dnd" | "offline"; declare type callbackFunc = (error: cbError, response: any) => void; -declare type WebSocketEvent = { - d: any; +declare type WebSocketEventReady = { + v: number; + user_settings: any; + user: Discord.User, + session_id: string; + relationships: any[]; + private_channels: any[]; + presences: any[]; + guilds: { + unavailable: boolean; + id: string; + }[]; + application: { + id: string; + flags: number; + }; + _trace: string[]; +}; + +declare type WebSocketEventMessage = { + type: number; + tts: boolean; + timestamp: string; + pinned: boolean; + nonce: string; + mentions: { + username: string; + member: Discord.Member; + id: string; + discriminator: string; + bot?: boolean; + avatar?: string; + }[]; + mention_roles: string[]; + mention_everyone: boolean; + member: Discord.Member; + id: string; + flags: number; + embeds: embedMessageOpts[]; + edited_timestamp?: any; + content: string; + channel_id: string; + author: Discord.User; + attachments: { + width: number; + height: number; + size: number; + id: string; + filename: string; + url: string; + proxy_url: string; + }[]; + guild_id: string; +}; + +declare type WebSocketEventPresence = { + user: Discord.User; + status: userStatus; + roles: string[]; + guild_id: string; + game?: game; + client_status: { + web?: userStatus; + desktop?: userStatus; + mobile?: userStatus; + }; + activities: game[]; +}; + +declare type WebSocketEvent = { + d: EventType; op: number; s: number; t: string; @@ -18,6 +87,9 @@ declare type game = { name: string; type: number; url?: string; + created_at?: number; + id?: string; + state?: string; }; declare type colors = "DEFAULT" | "AQUA" | "GREEN" | "BLUE" | "PURPLE" | "GOLD" | "ORANGE" | "RED" | "GREY" | "DARKER_GREY" | "NAVY" | "DARK_AQUA" | "DARK_GREEN" | "DARK_BLUE" | "DARK_PURPLE" | "DARK_GOLD" | "DARK_ORANGE" | "DARK_RED" | "DARK_GREY" | "LIGHT_GREY" | "DARK_NAVY"; @@ -28,9 +100,9 @@ declare type channelType = "voice" | "text"; /** * Events callbacks */ -declare type readyCallback = (event: WebSocketEvent) => void; -declare type messageCallback = (user: string, userID: string, channelID: string, mesage: string, event: WebSocketEvent) => void; -declare type presenceCallback = (user: string, userID: string, status: string, game: game, event: WebSocketEvent) => void; +declare type readyCallback = (event: WebSocketEvent) => void; +declare type messageCallback = (user: string, userID: string, channelID: string, message: string, event: WebSocketEvent) => void; +declare type presenceCallback = (user: string, userID: string, status: string, game: game, event: WebSocketEvent) => void; declare type anyCallback = (event: WebSocketEvent) => void; declare type disconnectCallback = (errMsg: string, code: number) => void; @@ -128,6 +200,7 @@ declare type sendMessageOpts = { } declare type embedMessageOpts = { + type?: string; author?: { icon_url?: string, name: string, @@ -135,11 +208,11 @@ declare type embedMessageOpts = { }, color?: number, description?: string, - fields?: [{ + fields?: { name: string, value?: string, inline?: boolean - }], + }[], thumbnail?: { url: string }, @@ -232,7 +305,7 @@ declare type setPresenceOpts = { declare type addAndRemoveFromRole = { serverID: string, userID: string, - role: string + roleID: string } declare type moveUserToOpts = { @@ -242,13 +315,13 @@ declare type moveUserToOpts = { } declare type actionsOnUserOpts = { - channelID: string, - target: string + serverID: string, + userID: string, } declare type banUserOpts = { - channelID: string, - target: string, + serverID: string, + userID: string, lastDays?: number } @@ -288,7 +361,7 @@ declare type editRoleOpts = { declare type deleteRoleOpts = { serverID: string, - role: string + roleID: string } declare type editNicknameOpts = { @@ -313,27 +386,27 @@ declare type editServerWidgetOpts = { } declare type addServerEmojiOpts = { - serverID: string, - name: string, - image: string + serverID: string, + name: string, + image: string } declare type editServerEmojiOpts = { - serverID: string, - emojiID: string, - name: string, - role: string[] + serverID: string, + emojiID: string, + name: string, + roleID: string[] } declare type deleteServerEmojiOpts = { - serverID: string, - emojiID: string + serverID: string, + emojiID: string } declare type deleteChannelPermissionOpts = { - channelID: string, - userID: string, - roleID: string + channelID: string, + userID: string, + roleID: string } declare type editNoteOpts = { @@ -411,12 +484,14 @@ declare namespace Discord { } export class User extends Resource { - username: string; + username?: string; id: string; - discriminator: number; - avatar: string; - bot: boolean; - game: Object; + discriminator?: string; + avatar?: string; + verified?: boolean; + mfa_enabled?: boolean; + email?: any; + bot?: boolean; } export class Member extends Resource { @@ -445,7 +520,7 @@ declare namespace Discord { id: string; username: string; email: string; - discriminator: number; + discriminator: string; avatar: string; bot: boolean; verified: boolean;