diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-05 22:01:01 +0100 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-02-05 22:01:01 +0100 |
commit | ea41892fef208b10c1bb322de7683c39ebab3dd5 (patch) | |
tree | f26559c73196591ac0338a21908a25c806276a7a | |
parent | Move Models/Schemas to server-util (diff) | |
download | server-ea41892fef208b10c1bb322de7683c39ebab3dd5.tar.xz |
:wrench: build
82 files changed, 1437 insertions, 21 deletions
diff --git a/dist/Config.js.map b/dist/Config.js.map deleted file mode 100644 index 35439efd..00000000 --- a/dist/Config.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AACrC,0DAA4B;AAE5B,IAAI,MAAqB,CAAC;AAE1B,kBAAe;IACd,IAAI,EAAE,KAAK,UAAU,IAAI,CAAC,OAAuB,sBAAc;QAC9D,MAAM,GAAG,kBAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,SAAS,GAAG;QACnB,OAAuB,MAAM,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,SAAS,GAAG,CAAC,GAAQ;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACD,CAAC;AAQW,QAAA,cAAc,GAAmB;IAC7C,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;CACT,CAAC"} \ No newline at end of file diff --git a/dist/Constants.js.map b/dist/Constants.js.map deleted file mode 100644 index 00d4855d..00000000 --- a/dist/Constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAkB,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/Database.js.map b/dist/Database.js.map deleted file mode 100644 index f40d2496..00000000 --- a/dist/Database.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Database.js","sourceRoot":"","sources":["../src/Database.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAE3C,6BAA6B;AAC7B,MAAM,EAAE,GAAG,IAAI,0BAAa,CAAC,qEAAqE,CAAC,CAAC;AAEpG,kBAAe,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/Schema/Activity.d.ts b/dist/Schema/Activity.d.ts new file mode 100644 index 00000000..420471a8 --- /dev/null +++ b/dist/Schema/Activity.d.ts @@ -0,0 +1,40 @@ +export declare const ActivitySchema: { + afk: BooleanConstructor; + status: StringConstructor; + $activities: { + name: StringConstructor; + type: NumberConstructor; + $url: StringConstructor; + $created_at: NumberConstructor; + $timestamps: { + start: NumberConstructor; + end: NumberConstructor; + }; + $application_id: BigIntConstructor; + $details: StringConstructor; + $State: StringConstructor; + $emoji: { + name: StringConstructor; + id: BigIntConstructor; + animated: BooleanConstructor; + }; + $party: { + $id: StringConstructor; + $size: NumberConstructor[]; + }; + $assets: { + $large_image: StringConstructor; + $large_text: StringConstructor; + $small_image: StringConstructor; + $small_text: StringConstructor; + }; + $secrets: { + $join: StringConstructor; + $spectate: StringConstructor; + $match: StringConstructor; + }; + $instance: BooleanConstructor; + flags: BigIntConstructor; + }[]; + $since: NumberConstructor; +}; diff --git a/dist/Schema/Activity.js b/dist/Schema/Activity.js new file mode 100644 index 00000000..cbca224c --- /dev/null +++ b/dist/Schema/Activity.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ActivitySchema = void 0; +const Emoji_1 = require("./Emoji"); +exports.ActivitySchema = { + afk: Boolean, + status: String, + $activities: [ + { + name: String, + type: Number, + $url: String, + $created_at: Number, + $timestamps: { + // unix timestamps for start and/or end of the game + start: Number, + end: Number, + }, + $application_id: BigInt, + $details: String, + $State: String, + $emoji: Emoji_1.EmojiSchema, + $party: { + $id: String, + $size: [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, + }, + ], + $since: Number, +}; +//# sourceMappingURL=Activity.js.map \ No newline at end of file diff --git a/dist/Schema/Activity.js.map b/dist/Schema/Activity.js.map new file mode 100644 index 00000000..587f92a8 --- /dev/null +++ b/dist/Schema/Activity.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../src/Schema/Activity.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEzB,QAAA,cAAc,GAAG;IAC7B,GAAG,EAAE,OAAO;IACZ,MAAM,EAAE,MAAM;IACd,WAAW,EAAE;QACZ;YACC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE;gBACZ,mDAAmD;gBACnD,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,MAAM;aACX;YACD,eAAe,EAAE,MAAM;YACvB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,mBAAW;YACnB,MAAM,EAAE;gBACP,GAAG,EAAE,MAAM;gBACX,KAAK,EAAE,CAAC,MAAM,CAAC;aACf;YACD,OAAO,EAAE;gBACR,YAAY,EAAE,MAAM;gBACpB,WAAW,EAAE,MAAM;gBACnB,YAAY,EAAE,MAAM;gBACpB,WAAW,EAAE,MAAM;aACnB;YACD,QAAQ,EAAE;gBACT,KAAK,EAAE,MAAM;gBACb,SAAS,EAAE,MAAM;gBACjB,MAAM,EAAE,MAAM;aACd;YACD,SAAS,EAAE,OAAO;YAClB,KAAK,EAAE,MAAM;SACb;KACD;IACD,MAAM,EAAE,MAAM;CACd,CAAC"} \ No newline at end of file diff --git a/dist/Schema/Emoji.d.ts b/dist/Schema/Emoji.d.ts new file mode 100644 index 00000000..81570e17 --- /dev/null +++ b/dist/Schema/Emoji.d.ts @@ -0,0 +1,5 @@ +export declare const EmojiSchema: { + name: StringConstructor; + id: BigIntConstructor; + animated: BooleanConstructor; +}; diff --git a/dist/Schema/Emoji.js b/dist/Schema/Emoji.js new file mode 100644 index 00000000..fe999d4e --- /dev/null +++ b/dist/Schema/Emoji.js @@ -0,0 +1,9 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EmojiSchema = void 0; +exports.EmojiSchema = { + name: String, + id: BigInt, + animated: Boolean, +}; +//# sourceMappingURL=Emoji.js.map \ No newline at end of file diff --git a/dist/Schema/Emoji.js.map b/dist/Schema/Emoji.js.map new file mode 100644 index 00000000..0d776e6d --- /dev/null +++ b/dist/Schema/Emoji.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Emoji.js","sourceRoot":"","sources":["../../src/Schema/Emoji.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,MAAM;IACV,QAAQ,EAAE,OAAO;CACjB,CAAC"} \ No newline at end of file diff --git a/dist/Schema/Identify.d.ts b/dist/Schema/Identify.d.ts new file mode 100644 index 00000000..be586093 --- /dev/null +++ b/dist/Schema/Identify.d.ts @@ -0,0 +1,53 @@ +export declare const IdentifySchema: { + token: StringConstructor; + properties: { + $$os: StringConstructor; + $$browser: StringConstructor; + $$device: StringConstructor; + }; + intents: BigIntConstructor; + $presence: { + afk: BooleanConstructor; + status: StringConstructor; + $activities: { + name: StringConstructor; + type: NumberConstructor; + $url: StringConstructor; + $created_at: NumberConstructor; + $timestamps: { + start: NumberConstructor; + end: NumberConstructor; + }; + $application_id: BigIntConstructor; + $details: StringConstructor; + $State: StringConstructor; + $emoji: { + name: StringConstructor; + id: BigIntConstructor; + animated: BooleanConstructor; + }; + $party: { + $id: StringConstructor; + $size: NumberConstructor[]; + }; + $assets: { + $large_image: StringConstructor; + $large_text: StringConstructor; + $small_image: StringConstructor; + $small_text: StringConstructor; + }; + $secrets: { + $join: StringConstructor; + $spectate: StringConstructor; + $match: StringConstructor; + }; + $instance: BooleanConstructor; + flags: BigIntConstructor; + }[]; + $since: NumberConstructor; + }; + $compress: BooleanConstructor; + $large_threshold: NumberConstructor; + $shard: NumberConstructor[]; + $guild_subscriptions: BooleanConstructor; +}; diff --git a/dist/Schema/Identify.js b/dist/Schema/Identify.js new file mode 100644 index 00000000..9686a4d0 --- /dev/null +++ b/dist/Schema/Identify.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IdentifySchema = void 0; +const Activity_1 = require("./Activity"); +exports.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, + $presence: Activity_1.ActivitySchema, + $compress: Boolean, + $large_threshold: Number, + $shard: [Number], + $guild_subscriptions: Boolean, +}; +//# sourceMappingURL=Identify.js.map \ No newline at end of file diff --git a/dist/Schema/Identify.js.map b/dist/Schema/Identify.js.map new file mode 100644 index 00000000..0feb6baa --- /dev/null +++ b/dist/Schema/Identify.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Identify.js","sourceRoot":"","sources":["../../src/Schema/Identify.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAE/B,QAAA,cAAc,GAAG;IAC7B,KAAK,EAAE,MAAM;IACb,UAAU,EAAE;QACX,yIAAyI;QACzI,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM;QACjB,QAAQ,EAAE,MAAM;KAChB;IACD,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,yBAAc;IACzB,SAAS,EAAE,OAAO;IAClB,gBAAgB,EAAE,MAAM;IACxB,MAAM,EAAE,CAAC,MAAM,CAAC;IAChB,oBAAoB,EAAE,OAAO;CAC7B,CAAC"} \ No newline at end of file diff --git a/dist/checkToken.js.map b/dist/checkToken.js.map deleted file mode 100644 index 2011f85b..00000000 --- a/dist/checkToken.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"checkToken.js","sourceRoot":"","sources":["../src/checkToken.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAyC;AACzC,gEAA+B;AAC/B,sDAA8B;AAE9B,SAAgB,UAAU,CAAC,KAAa;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,sBAAU,EAAE,CAAC,GAAG,EAAE,OAAY,EAAE,EAAE;YAC3F,IAAI,GAAG,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,eAAe,CAAC,CAAC;YAEjD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 45a3252d..271b83a1 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,6 +1,15 @@ -import { checkToken } from "./checkToken"; -import Config, { DefaultOptions } from "./Config"; -import { db } from "discord-server-util"; - -import * as Constants from "./Constants"; -export { checkToken, Config, Constants, db, DefaultOptions }; +import { checkToken } from "./util/checkToken"; +import Config, { DefaultOptions } from "./util/Config"; +import db from "./util/Database"; +import * as Constants from "./util/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"; +import { EmojiSchema } from "./Schema/Emoji"; +import { ActivitySchema } from "./Schema/Activity"; +import { IdentifySchema } from "./Schema/Identify"; +export { checkToken, Config, Constants, db, DefaultOptions, Channel, Emoji, Guild, Invite, Member, Role, User, EmojiSchema, ActivitySchema, IdentifySchema, }; diff --git a/dist/index.js b/dist/index.js index ecd64489..4c23cea2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -22,14 +22,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.DefaultOptions = exports.db = exports.Constants = exports.Config = exports.checkToken = void 0; -const checkToken_1 = require("./checkToken"); +exports.IdentifySchema = exports.ActivitySchema = exports.EmojiSchema = exports.DefaultOptions = exports.db = exports.Constants = exports.Config = exports.checkToken = void 0; +const checkToken_1 = require("./util/checkToken"); Object.defineProperty(exports, "checkToken", { enumerable: true, get: function () { return checkToken_1.checkToken; } }); -const Config_1 = __importStar(require("./Config")); +const Config_1 = __importStar(require("./util/Config")); exports.Config = Config_1.default; Object.defineProperty(exports, "DefaultOptions", { enumerable: true, get: function () { return Config_1.DefaultOptions; } }); -const Database_1 = __importDefault(require("./Database")); +const Database_1 = __importDefault(require("./util/Database")); exports.db = Database_1.default; -const Constants = __importStar(require("./Constants")); +const Constants = __importStar(require("./util/Constants")); exports.Constants = Constants; +const Emoji_1 = require("./Schema/Emoji"); +Object.defineProperty(exports, "EmojiSchema", { enumerable: true, get: function () { return Emoji_1.EmojiSchema; } }); +const Activity_1 = require("./Schema/Activity"); +Object.defineProperty(exports, "ActivitySchema", { enumerable: true, get: function () { return Activity_1.ActivitySchema; } }); +const Identify_1 = require("./Schema/Identify"); +Object.defineProperty(exports, "IdentifySchema", { enumerable: true, get: function () { return Identify_1.IdentifySchema; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index f5d21a46..83b31989 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA0C;AAKjC,2FALA,uBAAU,OAKA;AAJnB,mDAAkD;AAI7B,iBAJd,gBAAM,CAIc;AAAiB,+FAJ3B,uBAAc,OAI2B;AAH1D,0DAA4B;AAGY,aAHjC,kBAAE,CAGiC;AAF1C,uDAAyC;AAEZ,8BAAS"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA+C;AAgB9C,2FAhBQ,uBAAU,OAgBR;AAfX,wDAAuD;AAgBtD,iBAhBM,gBAAM,CAgBN;AAGN,+FAnBgB,uBAAc,OAmBhB;AAlBf,+DAAiC;AAiBhC,aAjBM,kBAAE,CAiBN;AAhBH,4DAA8C;AAe7C,8BAAS;AAPV,0CAA6C;AAiB5C,4FAjBQ,mBAAW,OAiBR;AAhBZ,gDAAmD;AAiBlD,+FAjBQ,yBAAc,OAiBR;AAhBf,gDAAmD;AAiBlD,+FAjBQ,yBAAc,OAiBR"} \ No newline at end of file diff --git a/dist/models/Channel.d.ts b/dist/models/Channel.d.ts new file mode 100644 index 00000000..f19071ef --- /dev/null +++ b/dist/models/Channel.d.ts @@ -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; + }[]; +} diff --git a/dist/models/Channel.js b/dist/models/Channel.js new file mode 100644 index 00000000..5d719d95 --- /dev/null +++ b/dist/models/Channel.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Channel.js.map \ No newline at end of file diff --git a/dist/models/Channel.js.map b/dist/models/Channel.js.map new file mode 100644 index 00000000..982f403e --- /dev/null +++ b/dist/models/Channel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Channel.js","sourceRoot":"","sources":["../../src/models/Channel.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/Emoji.d.ts b/dist/models/Emoji.d.ts new file mode 100644 index 00000000..e2f639db --- /dev/null +++ b/dist/models/Emoji.d.ts @@ -0,0 +1,12 @@ +export interface Emoji { + allNamesString: string; + animated: boolean; + available: boolean; + guildId: bigint; + id: bigint; + managed: boolean; + name: string; + require_colons: boolean; + url: string; + roles: []; +} diff --git a/dist/models/Emoji.js b/dist/models/Emoji.js new file mode 100644 index 00000000..f4bbad78 --- /dev/null +++ b/dist/models/Emoji.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Emoji.js.map \ No newline at end of file diff --git a/dist/models/Emoji.js.map b/dist/models/Emoji.js.map new file mode 100644 index 00000000..3127e84e --- /dev/null +++ b/dist/models/Emoji.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Emoji.js","sourceRoot":"","sources":["../../src/models/Emoji.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/Guild.d.ts b/dist/models/Guild.d.ts new file mode 100644 index 00000000..ea212c92 --- /dev/null +++ b/dist/models/Guild.d.ts @@ -0,0 +1,52 @@ +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: []; + members: Member[]; + channels: Channel[]; + presences: []; + 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: []; +} diff --git a/dist/models/Guild.js b/dist/models/Guild.js new file mode 100644 index 00000000..6c1c7bc5 --- /dev/null +++ b/dist/models/Guild.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Guild.js.map \ No newline at end of file diff --git a/dist/models/Guild.js.map b/dist/models/Guild.js.map new file mode 100644 index 00000000..0cd8adb1 --- /dev/null +++ b/dist/models/Guild.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Guild.js","sourceRoot":"","sources":["../../src/models/Guild.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/Invite.d.ts b/dist/models/Invite.d.ts new file mode 100644 index 00000000..e68886c6 --- /dev/null +++ b/dist/models/Invite.d.ts @@ -0,0 +1,30 @@ +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; +} diff --git a/dist/models/Invite.js b/dist/models/Invite.js new file mode 100644 index 00000000..ff9594fe --- /dev/null +++ b/dist/models/Invite.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Invite.js.map \ No newline at end of file diff --git a/dist/models/Invite.js.map b/dist/models/Invite.js.map new file mode 100644 index 00000000..a5340046 --- /dev/null +++ b/dist/models/Invite.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Invite.js","sourceRoot":"","sources":["../../src/models/Invite.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/Member.d.ts b/dist/models/Member.d.ts new file mode 100644 index 00000000..0ccdd5fe --- /dev/null +++ b/dist/models/Member.d.ts @@ -0,0 +1,13 @@ +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; +} diff --git a/dist/models/Member.js b/dist/models/Member.js new file mode 100644 index 00000000..0a75bf46 --- /dev/null +++ b/dist/models/Member.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Member.js.map \ No newline at end of file diff --git a/dist/models/Member.js.map b/dist/models/Member.js.map new file mode 100644 index 00000000..2a0d5623 --- /dev/null +++ b/dist/models/Member.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Member.js","sourceRoot":"","sources":["../../src/models/Member.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/Role.d.ts b/dist/models/Role.d.ts new file mode 100644 index 00000000..8e8042c1 --- /dev/null +++ b/dist/models/Role.d.ts @@ -0,0 +1,9 @@ +export interface Role { + color: number; + hoist: boolean; + managed: boolean; + mentionable: boolean; + name: string; + permissions: bigint; + position: number; +} diff --git a/dist/models/Role.js b/dist/models/Role.js new file mode 100644 index 00000000..467f4294 --- /dev/null +++ b/dist/models/Role.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=Role.js.map \ No newline at end of file diff --git a/dist/models/Role.js.map b/dist/models/Role.js.map new file mode 100644 index 00000000..74ec8cab --- /dev/null +++ b/dist/models/Role.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../src/models/Role.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/models/User.d.ts b/dist/models/User.d.ts new file mode 100644 index 00000000..f5676386 --- /dev/null +++ b/dist/models/User.d.ts @@ -0,0 +1,60 @@ +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; + hash: string; + valid_tokens_since: number; + 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: { + color: number; + guild_ids: bigint[]; + id: number; + name: string; + }[]; + guild_positions: bigint[]; + inline_attachment_media: boolean; + inline_embed_media: boolean; + locale: string; + 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"; + timezone_offset: number; +} diff --git a/dist/models/User.js b/dist/models/User.js new file mode 100644 index 00000000..9da5871e --- /dev/null +++ b/dist/models/User.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=User.js.map \ No newline at end of file diff --git a/dist/models/User.js.map b/dist/models/User.js.map new file mode 100644 index 00000000..55984657 --- /dev/null +++ b/dist/models/User.js.map @@ -0,0 +1 @@ +{"version":3,"file":"User.js","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/util/BitField.d.ts b/dist/util/BitField.d.ts new file mode 100644 index 00000000..1b08c1f8 --- /dev/null +++ b/dist/util/BitField.d.ts @@ -0,0 +1,66 @@ +export declare type BitFieldResolvable = number | BigInt | BitField | string | BitFieldResolvable[]; +/** + * Data structure that makes it easy to interact with a bitfield. + */ +export declare class BitField { + bitfield: bigint; + static FLAGS: Record<string, bigint>; + constructor(bits?: BitFieldResolvable); + /** + * Checks whether the bitfield has a bit, or any of multiple bits. + */ + any(bit: BitFieldResolvable): boolean; + /** + * Checks if this bitfield equals another + */ + equals(bit: BitFieldResolvable): boolean; + /** + * Checks whether the bitfield has a bit, or multiple bits. + */ + has(bit: BitFieldResolvable): boolean; + /** + * Gets all given bits that are missing from the bitfield. + */ + missing(bits: BitFieldResolvable): BitFieldResolvable[]; + /** + * Freezes these bits, making them immutable. + */ + freeze(): Readonly<BitField>; + /** + * Adds bits to these ones. + * @param {...BitFieldResolvable} [bits] Bits to add + * @returns {BitField} These bits or new BitField if the instance is frozen. + */ + add(...bits: BitFieldResolvable[]): BitField; + /** + * Removes bits from these. + * @param {...BitFieldResolvable} [bits] Bits to remove + */ + remove(...bits: BitFieldResolvable[]): BitField; + /** + * Gets an object mapping field names to a {@link boolean} indicating whether the + * bit is available. + * @param {...*} hasParams Additional parameters for the has method, if any + */ + serialize(): Record<string, boolean>; + /** + * Gets an {@link Array} of bitfield names based on the bits available. + */ + toArray(): string[]; + toJSON(): bigint; + valueOf(): bigint; + [Symbol.iterator](): Generator<string, void, undefined>; + /** + * Data that can be resolved to give a bitfield. This can be: + * * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS}) + * * An instance of BitField + * * An Array of BitFieldResolvable + * @typedef {number|BitField|BitFieldResolvable[]} BitFieldResolvable + */ + /** + * Resolves bitfields to their numeric form. + * @param {BitFieldResolvable} [bit=0] - bit(s) to resolve + * @returns {number} + */ + static resolve(bit?: BitFieldResolvable): bigint; +} diff --git a/dist/util/BitField.js b/dist/util/BitField.js new file mode 100644 index 00000000..97d76f3a --- /dev/null +++ b/dist/util/BitField.js @@ -0,0 +1,127 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.BitField = void 0; +/** + * Data structure that makes it easy to interact with a bitfield. + */ +class BitField { + constructor(bits = 0) { + this.bitfield = BigInt(0); + this.bitfield = BitField.resolve(bits); + } + /** + * Checks whether the bitfield has a bit, or any of multiple bits. + */ + any(bit) { + return (this.bitfield & BitField.resolve(bit)) !== 0n; + } + /** + * Checks if this bitfield equals another + */ + equals(bit) { + return this.bitfield === BitField.resolve(bit); + } + /** + * Checks whether the bitfield has a bit, or multiple bits. + */ + has(bit) { + if (Array.isArray(bit)) + return bit.every((p) => this.has(p)); + const BIT = BitField.resolve(bit); + return (this.bitfield & BIT) === BIT; + } + /** + * Gets all given bits that are missing from the bitfield. + */ + missing(bits) { + if (!Array.isArray(bits)) + bits = new BitField(bits).toArray(); + return bits.filter((p) => !this.has(p)); + } + /** + * Freezes these bits, making them immutable. + */ + freeze() { + return Object.freeze(this); + } + /** + * Adds bits to these ones. + * @param {...BitFieldResolvable} [bits] Bits to add + * @returns {BitField} These bits or new BitField if the instance is frozen. + */ + add(...bits) { + let total = 0n; + for (const bit of bits) { + total |= BitField.resolve(bit); + } + if (Object.isFrozen(this)) + return new BitField(this.bitfield | total); + this.bitfield |= total; + return this; + } + /** + * Removes bits from these. + * @param {...BitFieldResolvable} [bits] Bits to remove + */ + remove(...bits) { + let total = 0n; + for (const bit of bits) { + total |= BitField.resolve(bit); + } + if (Object.isFrozen(this)) + return new BitField(this.bitfield & ~total); + this.bitfield &= ~total; + return this; + } + /** + * Gets an object mapping field names to a {@link boolean} indicating whether the + * bit is available. + * @param {...*} hasParams Additional parameters for the has method, if any + */ + serialize() { + const serialized = {}; + for (const [flag, bit] of Object.entries(BitField.FLAGS)) + serialized[flag] = this.has(bit); + return serialized; + } + /** + * Gets an {@link Array} of bitfield names based on the bits available. + */ + toArray() { + return Object.keys(BitField.FLAGS).filter((bit) => this.has(bit)); + } + toJSON() { + return this.bitfield; + } + valueOf() { + return this.bitfield; + } + *[Symbol.iterator]() { + yield* this.toArray(); + } + /** + * Data that can be resolved to give a bitfield. This can be: + * * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS}) + * * An instance of BitField + * * An Array of BitFieldResolvable + * @typedef {number|BitField|BitFieldResolvable[]} BitFieldResolvable + */ + /** + * Resolves bitfields to their numeric form. + * @param {BitFieldResolvable} [bit=0] - bit(s) to resolve + * @returns {number} + */ + static resolve(bit = 0n) { + if ((typeof bit === "number" || typeof bit === "bigint") && bit >= 0n) + return BigInt(bit); + if (bit instanceof BitField) + return bit.bitfield; + if (Array.isArray(bit)) + return bit.map((p) => this.resolve(p)).reduce((prev, p) => BigInt(prev) | BigInt(p), 0n); + if (typeof bit === "string" && typeof this.FLAGS[bit] !== "undefined") + return this.FLAGS[bit]; + throw new RangeError("BITFIELD_INVALID: " + bit); + } +} +exports.BitField = BitField; +//# sourceMappingURL=BitField.js.map \ No newline at end of file diff --git a/dist/util/BitField.js.map b/dist/util/BitField.js.map new file mode 100644 index 00000000..5cf7dca0 --- /dev/null +++ b/dist/util/BitField.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BitField.js","sourceRoot":"","sources":["../../src/util/BitField.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAOb;;GAEG;AACH,MAAa,QAAQ;IAKpB,YAAY,OAA2B,CAAC;QAJjC,aAAQ,GAAW,MAAM,CAAC,CAAC,CAAC,CAAC;QAKnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,GAAuB;QAC1B,OAAO,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACvD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAuB;QAC7B,OAAO,IAAI,CAAC,QAAQ,KAAK,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AAE;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1F,IAAI,GAAG,YAAY,QAAQ;YAAE,OAAO,GAAG,CAAC,QAAQ,CAAC;QACjD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;YACrB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1F,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,WAAW;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9F,MAAM,IAAI,UAAU,CAAC,oBAAoB,GAAG,GAAG,CAAC,CAAC;IAClD,CAAC;CACD;AA/HD,4BA+HC"} \ No newline at end of file diff --git a/dist/Config.d.ts b/dist/util/Config.d.ts index 2ab792f5..2ab792f5 100644 --- a/dist/Config.d.ts +++ b/dist/util/Config.d.ts diff --git a/dist/Config.js b/dist/util/Config.js index 948f09d6..948f09d6 100644 --- a/dist/Config.js +++ b/dist/util/Config.js diff --git a/dist/util/Config.js.map b/dist/util/Config.js.map new file mode 100644 index 00000000..af36df3c --- /dev/null +++ b/dist/util/Config.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Config.js","sourceRoot":"","sources":["../../src/util/Config.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAqC;AACrC,0DAA4B;AAE5B,IAAI,MAAqB,CAAC;AAE1B,kBAAe;IACd,IAAI,EAAE,KAAK,UAAU,IAAI,CAAC,OAAuB,sBAAc;QAC9D,MAAM,GAAG,kBAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,MAAM,EAAE,SAAS,GAAG;QACnB,OAAuB,MAAM,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;IACD,MAAM,EAAE,SAAS,GAAG,CAAC,GAAQ;QAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;CACD,CAAC;AAQW,QAAA,cAAc,GAAmB;IAC7C,GAAG,EAAE,EAAE;IACP,OAAO,EAAE,EAAE;IACX,KAAK,EAAE,EAAE;CACT,CAAC"} \ No newline at end of file diff --git a/dist/Constants.d.ts b/dist/util/Constants.d.ts index ecceb4e6..ecceb4e6 100644 --- a/dist/Constants.d.ts +++ b/dist/util/Constants.d.ts diff --git a/dist/Constants.js b/dist/util/Constants.js index d65f8185..d65f8185 100644 --- a/dist/Constants.js +++ b/dist/util/Constants.js diff --git a/dist/util/Constants.js.map b/dist/util/Constants.js.map new file mode 100644 index 00000000..cf06fd23 --- /dev/null +++ b/dist/util/Constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/util/Constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAkB,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/Database.d.ts b/dist/util/Database.d.ts index 1a45ea78..1a45ea78 100644 --- a/dist/Database.d.ts +++ b/dist/util/Database.d.ts diff --git a/dist/Database.js b/dist/util/Database.js index 9fe58f0a..9fe58f0a 100644 --- a/dist/Database.js +++ b/dist/util/Database.js diff --git a/dist/util/Database.js.map b/dist/util/Database.js.map new file mode 100644 index 00000000..11227ca7 --- /dev/null +++ b/dist/util/Database.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../src/util/Database.ts"],"names":[],"mappings":";;AAAA,2CAA2C;AAE3C,6BAA6B;AAC7B,MAAM,EAAE,GAAG,IAAI,0BAAa,CAAC,qEAAqE,CAAC,CAAC;AAEpG,kBAAe,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/util/Intents.d.ts b/dist/util/Intents.d.ts new file mode 100644 index 00000000..bf8bac90 --- /dev/null +++ b/dist/util/Intents.d.ts @@ -0,0 +1,20 @@ +import { BitField } from "./BitField"; +export declare class Intents extends BitField { + static FLAGS: { + GUILDS: bigint; + GUILD_MEMBERS: bigint; + GUILD_BANS: bigint; + GUILD_EMOJIS: bigint; + GUILD_INTEGRATIONS: bigint; + GUILD_WEBHOOKS: bigint; + GUILD_INVITES: bigint; + GUILD_VOICE_STATES: bigint; + GUILD_PRESENCES: bigint; + GUILD_MESSAGES: bigint; + GUILD_MESSAGE_REACTIONS: bigint; + GUILD_MESSAGE_TYPING: bigint; + DIRECT_MESSAGES: bigint; + DIRECT_MESSAGE_REACTIONS: bigint; + DIRECT_MESSAGE_TYPING: bigint; + }; +} diff --git a/dist/util/Intents.js b/dist/util/Intents.js new file mode 100644 index 00000000..5a7baa8c --- /dev/null +++ b/dist/util/Intents.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Intents = void 0; +const BitField_1 = require("./BitField"); +class Intents extends BitField_1.BitField { +} +exports.Intents = Intents; +Intents.FLAGS = { + GUILDS: 1n << 0n, + GUILD_MEMBERS: 1n << 1n, + GUILD_BANS: 1n << 2n, + GUILD_EMOJIS: 1n << 3n, + GUILD_INTEGRATIONS: 1n << 4n, + GUILD_WEBHOOKS: 1n << 5n, + GUILD_INVITES: 1n << 6n, + GUILD_VOICE_STATES: 1n << 7n, + GUILD_PRESENCES: 1n << 8n, + GUILD_MESSAGES: 1n << 9n, + GUILD_MESSAGE_REACTIONS: 1n << 10n, + GUILD_MESSAGE_TYPING: 1n << 11n, + DIRECT_MESSAGES: 1n << 12n, + DIRECT_MESSAGE_REACTIONS: 1n << 13n, + DIRECT_MESSAGE_TYPING: 1n << 14n, +}; +//# sourceMappingURL=Intents.js.map \ No newline at end of file diff --git a/dist/util/Intents.js.map b/dist/util/Intents.js.map new file mode 100644 index 00000000..7250c839 --- /dev/null +++ b/dist/util/Intents.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Intents.js","sourceRoot":"","sources":["../../src/util/Intents.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AAEtC,MAAa,OAAQ,SAAQ,mBAAQ;;AAArC,0BAkBC;AAjBO,aAAK,GAAG;IACd,MAAM,EAAE,EAAE,IAAI,EAAE;IAChB,aAAa,EAAE,EAAE,IAAI,EAAE;IACvB,UAAU,EAAE,EAAE,IAAI,EAAE;IACpB,YAAY,EAAE,EAAE,IAAI,EAAE;IACtB,kBAAkB,EAAE,EAAE,IAAI,EAAE;IAC5B,cAAc,EAAE,EAAE,IAAI,EAAE;IACxB,aAAa,EAAE,EAAE,IAAI,EAAE;IACvB,kBAAkB,EAAE,EAAE,IAAI,EAAE;IAC5B,eAAe,EAAE,EAAE,IAAI,EAAE;IACzB,cAAc,EAAE,EAAE,IAAI,EAAE;IACxB,uBAAuB,EAAE,EAAE,IAAI,GAAG;IAClC,oBAAoB,EAAE,EAAE,IAAI,GAAG;IAC/B,eAAe,EAAE,EAAE,IAAI,GAAG;IAC1B,wBAAwB,EAAE,EAAE,IAAI,GAAG;IACnC,qBAAqB,EAAE,EAAE,IAAI,GAAG;CAChC,CAAC"} \ No newline at end of file diff --git a/dist/util/MessageFlags.d.ts b/dist/util/MessageFlags.d.ts new file mode 100644 index 00000000..9a0a8e40 --- /dev/null +++ b/dist/util/MessageFlags.d.ts @@ -0,0 +1,10 @@ +import { BitField } from "./BitField"; +export declare class MessageFlags extends BitField { + static FLAGS: { + CROSSPOSTED: bigint; + IS_CROSSPOST: bigint; + SUPPRESS_EMBEDS: bigint; + SOURCE_MESSAGE_DELETED: bigint; + URGENT: bigint; + }; +} diff --git a/dist/util/MessageFlags.js b/dist/util/MessageFlags.js new file mode 100644 index 00000000..bdfed0fe --- /dev/null +++ b/dist/util/MessageFlags.js @@ -0,0 +1,17 @@ +"use strict"; +// https://github.com/discordjs/discord.js/blob/master/src/util/MessageFlags.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MessageFlags = void 0; +const BitField_1 = require("./BitField"); +class MessageFlags extends BitField_1.BitField { +} +exports.MessageFlags = MessageFlags; +MessageFlags.FLAGS = { + CROSSPOSTED: 1n << 0n, + IS_CROSSPOST: 1n << 1n, + SUPPRESS_EMBEDS: 1n << 2n, + SOURCE_MESSAGE_DELETED: 1n << 3n, + URGENT: 1n << 4n, +}; +//# sourceMappingURL=MessageFlags.js.map \ No newline at end of file diff --git a/dist/util/MessageFlags.js.map b/dist/util/MessageFlags.js.map new file mode 100644 index 00000000..3aad5ea1 --- /dev/null +++ b/dist/util/MessageFlags.js.map @@ -0,0 +1 @@ +{"version":3,"file":"MessageFlags.js","sourceRoot":"","sources":["../../src/util/MessageFlags.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,8DAA8D;;;AAE9D,yCAAsC;AAEtC,MAAa,YAAa,SAAQ,mBAAQ;;AAA1C,oCAQC;AAPO,kBAAK,GAAG;IACd,WAAW,EAAE,EAAE,IAAI,EAAE;IACrB,YAAY,EAAE,EAAE,IAAI,EAAE;IACtB,eAAe,EAAE,EAAE,IAAI,EAAE;IACzB,sBAAsB,EAAE,EAAE,IAAI,EAAE;IAChC,MAAM,EAAE,EAAE,IAAI,EAAE;CAChB,CAAC"} \ No newline at end of file diff --git a/dist/util/Permissions.d.ts b/dist/util/Permissions.d.ts new file mode 100644 index 00000000..8373f7c8 --- /dev/null +++ b/dist/util/Permissions.d.ts @@ -0,0 +1,45 @@ +import { BitField } from "./BitField"; +export declare type PermissionResolvable = string | number | Permissions | PermissionResolvable[]; +export declare class Permissions extends BitField { + static FLAGS: { + CREATE_INSTANT_INVITE: bigint; + KICK_MEMBERS: bigint; + BAN_MEMBERS: bigint; + ADMINISTRATOR: bigint; + MANAGE_CHANNELS: bigint; + MANAGE_GUILD: bigint; + ADD_REACTIONS: bigint; + VIEW_AUDIT_LOG: bigint; + PRIORITY_SPEAKER: bigint; + STREAM: bigint; + VIEW_CHANNEL: bigint; + SEND_MESSAGES: bigint; + SEND_TTS_MESSAGES: bigint; + MANAGE_MESSAGES: bigint; + EMBED_LINKS: bigint; + ATTACH_FILES: bigint; + READ_MESSAGE_HISTORY: bigint; + MENTION_EVERYONE: bigint; + USE_EXTERNAL_EMOJIS: bigint; + VIEW_GUILD_INSIGHTS: bigint; + CONNECT: bigint; + SPEAK: bigint; + MUTE_MEMBERS: bigint; + DEAFEN_MEMBERS: bigint; + MOVE_MEMBERS: bigint; + USE_VAD: bigint; + CHANGE_NICKNAME: bigint; + MANAGE_NICKNAMES: bigint; + MANAGE_ROLES: bigint; + MANAGE_WEBHOOKS: bigint; + MANAGE_EMOJIS: bigint; + }; + any(permission: PermissionResolvable, checkAdmin?: boolean): boolean; + /** + * Checks whether the bitfield has a permission, or multiple permissions. + * @param {PermissionResolvable} permission Permission(s) to check for + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {boolean} + */ + has(permission: PermissionResolvable, checkAdmin?: boolean): boolean; +} diff --git a/dist/util/Permissions.js b/dist/util/Permissions.js new file mode 100644 index 00000000..596e1fa9 --- /dev/null +++ b/dist/util/Permissions.js @@ -0,0 +1,55 @@ +"use strict"; +// https://github.com/discordjs/discord.js/blob/master/src/util/Permissions.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Permissions = void 0; +const BitField_1 = require("./BitField"); +class Permissions extends BitField_1.BitField { + any(permission, checkAdmin = true) { + return (checkAdmin && super.has(Permissions.FLAGS.ADMINISTRATOR)) || super.any(permission); + } + /** + * Checks whether the bitfield has a permission, or multiple permissions. + * @param {PermissionResolvable} permission Permission(s) to check for + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {boolean} + */ + has(permission, checkAdmin = true) { + return (checkAdmin && super.has(Permissions.FLAGS.ADMINISTRATOR)) || super.has(permission); + } +} +exports.Permissions = Permissions; +Permissions.FLAGS = { + CREATE_INSTANT_INVITE: 1n << 0n, + KICK_MEMBERS: 1n << 1n, + BAN_MEMBERS: 1n << 2n, + ADMINISTRATOR: 1n << 3n, + MANAGE_CHANNELS: 1n << 4n, + MANAGE_GUILD: 1n << 5n, + ADD_REACTIONS: 1n << 6n, + VIEW_AUDIT_LOG: 1n << 7n, + PRIORITY_SPEAKER: 1n << 8n, + STREAM: 1n << 9n, + VIEW_CHANNEL: 1n << 10n, + SEND_MESSAGES: 1n << 11n, + SEND_TTS_MESSAGES: 1n << 12n, + MANAGE_MESSAGES: 1n << 13n, + EMBED_LINKS: 1n << 14n, + ATTACH_FILES: 1n << 15n, + READ_MESSAGE_HISTORY: 1n << 16n, + MENTION_EVERYONE: 1n << 17n, + USE_EXTERNAL_EMOJIS: 1n << 18n, + VIEW_GUILD_INSIGHTS: 1n << 19n, + CONNECT: 1n << 20n, + SPEAK: 1n << 21n, + MUTE_MEMBERS: 1n << 22n, + DEAFEN_MEMBERS: 1n << 23n, + MOVE_MEMBERS: 1n << 24n, + USE_VAD: 1n << 25n, + CHANGE_NICKNAME: 1n << 26n, + MANAGE_NICKNAMES: 1n << 27n, + MANAGE_ROLES: 1n << 28n, + MANAGE_WEBHOOKS: 1n << 29n, + MANAGE_EMOJIS: 1n << 30n, +}; +//# sourceMappingURL=Permissions.js.map \ No newline at end of file diff --git a/dist/util/Permissions.js.map b/dist/util/Permissions.js.map new file mode 100644 index 00000000..2e8e4e50 --- /dev/null +++ b/dist/util/Permissions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../src/util/Permissions.ts"],"names":[],"m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AmB,EAAE,EAAE,IAAI,GAAG;IAC9B,mBAAmB,EAAE,EAAE,IAAI,GAAG;IAC9B,OAAO,EAAE,EAAE,IAAI,GAAG;IAClB,KAAK,EAAE,EAAE,IAAI,GAAG;IAChB,YAAY,EAAE,EAAE,IAAI,GAAG;IACvB,cAAc,EAAE,EAAE,IAAI,GAAG;IACzB,YAAY,EAAE,EAAE,IAAI,GAAG;IACvB,OAAO,EAAE,EAAE,IAAI,GAAG;IAClB,eAAe,EAAE,EAAE,IAAI,GAAG;IAC1B,gBAAgB,EAAE,EAAE,IAAI,GAAG;IAC3B,YAAY,EAAE,EAAE,IAAI,GAAG;IACvB,eAAe,EAAE,EAAE,IAAI,GAAG;IAC1B,aAAa,EAAE,EAAE,IAAI,GAAG;CACxB,CAAC"} \ No newline at end of file diff --git a/dist/util/Snowflake.d.ts b/dist/util/Snowflake.d.ts new file mode 100644 index 00000000..bd8c05bb --- /dev/null +++ b/dist/util/Snowflake.d.ts @@ -0,0 +1,58 @@ +/** + * A container for useful snowflake-related methods. + */ +export declare class Snowflake { + static readonly EPOCH = 1420070400000; + static INCREMENT: bigint; + static processId: bigint; + static workerId: bigint; + constructor(); + /** + * A Twitter snowflake, except the epoch is 2015-01-01T00:00:00.000Z + * ``` + * If we have a snowflake '266241948824764416' we can represent it as binary: + * + * 64 22 17 12 0 + * 000000111011000111100001101001000101000000 00001 00000 000000000000 + * number of ms since Discord epoch worker pid increment + * ``` + * @typedef {string} Snowflake + */ + /** + * Transforms a snowflake from a decimal string to a bit string. + * @param {Snowflake} num Snowflake to be transformed + * @returns {string} + * @private + */ + static idToBinary(num: any): string; + /** + * Transforms a snowflake from a bit string to a decimal string. + * @param {string} num Bit string to be transformed + * @returns {Snowflake} + * @private + */ + static binaryToID(num: any): string; + static generate(): bigint; + /** + * A deconstructed snowflake. + * @typedef {Object} DeconstructedSnowflake + * @property {number} timestamp Timestamp the snowflake was created + * @property {Date} date Date the snowflake was created + * @property {number} workerID Worker ID in the snowflake + * @property {number} processID Process ID in the snowflake + * @property {number} increment Increment in the snowflake + * @property {string} binary Binary representation of the snowflake + */ + /** + * Deconstructs a Discord snowflake. + * @param {Snowflake} snowflake Snowflake to deconstruct + * @returns {DeconstructedSnowflake} Deconstructed snowflake + */ + static deconstruct(snowflake: any): { + timestamp: any; + workerID: number; + processID: number; + increment: number; + binary: string; + }; +} diff --git a/dist/util/Snowflake.js b/dist/util/Snowflake.js new file mode 100644 index 00000000..78373e95 --- /dev/null +++ b/dist/util/Snowflake.js @@ -0,0 +1,116 @@ +// @ts-nocheck +// https://github.com/discordjs/discord.js/blob/master/src/util/Snowflake.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Snowflake = void 0; +// Discord epoch (2015-01-01T00:00:00.000Z) +/** + * A container for useful snowflake-related methods. + */ +class Snowflake { + constructor() { + throw new Error(`The ${this.constructor.name} class may not be instantiated.`); + } + /** + * A Twitter snowflake, except the epoch is 2015-01-01T00:00:00.000Z + * ``` + * If we have a snowflake '266241948824764416' we can represent it as binary: + * + * 64 22 17 12 0 + * 000000111011000111100001101001000101000000 00001 00000 000000000000 + * number of ms since Discord epoch worker pid increment + * ``` + * @typedef {string} Snowflake + */ + /** + * Transforms a snowflake from a decimal string to a bit string. + * @param {Snowflake} num Snowflake to be transformed + * @returns {string} + * @private + */ + static idToBinary(num) { + let bin = ""; + let high = parseInt(num.slice(0, -10)) || 0; + let low = parseInt(num.slice(-10)); + while (low > 0 || high > 0) { + bin = String(low & 1) + bin; + low = Math.floor(low / 2); + if (high > 0) { + low += 5000000000 * (high % 2); + high = Math.floor(high / 2); + } + } + return bin; + } + /** + * Transforms a snowflake from a bit string to a decimal string. + * @param {string} num Bit string to be transformed + * @returns {Snowflake} + * @private + */ + static binaryToID(num) { + let dec = ""; + while (num.length > 50) { + const high = parseInt(num.slice(0, -32), 2); + const low = parseInt((high % 10).toString(2) + num.slice(-32), 2); + dec = (low % 10).toString() + dec; + num = + Math.floor(high / 10).toString(2) + + Math.floor(low / 10) + .toString(2) + .padStart(32, "0"); + } + num = parseInt(num, 2); + while (num > 0) { + dec = (num % 10).toString() + dec; + num = Math.floor(num / 10); + } + return dec; + } + static generate() { + var time = BigInt(Date.now() - Snowflake.EPOCH) << 22n; + var worker = Snowflake.workerId << 17n; + var process = Snowflake.processId << 12n; + var increment = Snowflake.INCREMENT++; + return time | worker | process | increment; + } + /** + * A deconstructed snowflake. + * @typedef {Object} DeconstructedSnowflake + * @property {number} timestamp Timestamp the snowflake was created + * @property {Date} date Date the snowflake was created + * @property {number} workerID Worker ID in the snowflake + * @property {number} processID Process ID in the snowflake + * @property {number} increment Increment in the snowflake + * @property {string} binary Binary representation of the snowflake + */ + /** + * Deconstructs a Discord snowflake. + * @param {Snowflake} snowflake Snowflake to deconstruct + * @returns {DeconstructedSnowflake} Deconstructed snowflake + */ + static deconstruct(snowflake) { + const BINARY = Snowflake.idToBinary(snowflake).toString(2).padStart(64, "0"); + const res = { + timestamp: parseInt(BINARY.substring(0, 42), 2) + EPOCH, + workerID: parseInt(BINARY.substring(42, 47), 2), + processID: parseInt(BINARY.substring(47, 52), 2), + increment: parseInt(BINARY.substring(52, 64), 2), + binary: BINARY, + }; + Object.defineProperty(res, "date", { + get: function get() { + return new Date(this.timestamp); + }, + enumerable: true, + }); + return res; + } +} +exports.Snowflake = Snowflake; +Snowflake.EPOCH = 1420070400000; +Snowflake.INCREMENT = 0n; // max 4095 +Snowflake.processId = 0n; // max 31 +Snowflake.workerId = 0n; // max 31 +//# sourceMappingURL=Snowflake.js.map \ No newline at end of file diff --git a/dist/util/Snowflake.js.map b/dist/util/Snowflake.js.map new file mode 100644 index 00000000..9d4b3195 --- /dev/null +++ b/dist/util/Snowflake.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Snowflake.js","sourceRoot":"","sources":["../../src/util/Snowflake.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,4EAA4E;AAC5E,8DAA8D;A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AS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7E,MAAM,GAAG,GAAG;YACX,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;YACvD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAC/C,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAChD,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAChD,MAAM,EAAE,MAAM;SACd,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE;YAClC,GAAG,EAAE,SAAS,GAAG;gBAChB,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjC,CAAC;YACD,UAAU,EAAE,IAAI;SAChB,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACZ,CAAC;;AAjHF,8BAkHC;AAjHgB,eAAK,GAAG,aAAa,CAAC;AAC/B,mBAAS,GAAG,EAAE,CAAC,CAAC,WAAW;AAC3B,mBAAS,GAAG,EAAE,CAAC,CAAC,SAAS;AACzB,kBAAQ,GAAG,EAAE,CAAC,CAAC,SAAS"} \ No newline at end of file diff --git a/dist/util/String.d.ts b/dist/util/String.d.ts new file mode 100644 index 00000000..0ec4281e --- /dev/null +++ b/dist/util/String.d.ts @@ -0,0 +1,3 @@ +export declare const DOUBLE_WHITE_SPACE: RegExp; +export declare const SPECIAL_CHAR: RegExp; +export declare function trimSpecial(str: string): string; diff --git a/dist/util/String.js b/dist/util/String.js new file mode 100644 index 00000000..712328ef --- /dev/null +++ b/dist/util/String.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.trimSpecial = exports.SPECIAL_CHAR = exports.DOUBLE_WHITE_SPACE = void 0; +exports.DOUBLE_WHITE_SPACE = /\s\s+/g; +exports.SPECIAL_CHAR = /[@#`:\r\n\t\f\v\p{C}]/gu; +function trimSpecial(str) { + return str.replace(exports.SPECIAL_CHAR, "").replace(exports.DOUBLE_WHITE_SPACE, " ").trim(); +} +exports.trimSpecial = trimSpecial; +//# sourceMappingURL=String.js.map \ No newline at end of file diff --git a/dist/util/String.js.map b/dist/util/String.js.map new file mode 100644 index 00000000..83644ad9 --- /dev/null +++ b/dist/util/String.js.map @@ -0,0 +1 @@ +{"version":3,"file":"String.js","sourceRoot":"","sources":["../../src/util/String.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAC9B,QAAA,YAAY,GAAG,yBAAyB,CAAC;AAEtD,SAAgB,WAAW,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,oBAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,0BAAkB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,CAAC;AAFD,kCAEC"} \ No newline at end of file diff --git a/dist/util/UserFlags.d.ts b/dist/util/UserFlags.d.ts new file mode 100644 index 00000000..b721d61c --- /dev/null +++ b/dist/util/UserFlags.d.ts @@ -0,0 +1,18 @@ +import { BitField } from "./BitField"; +export declare class UserFlags extends BitField { + static FLAGS: { + DISCORD_EMPLOYEE: bigint; + PARTNERED_SERVER_OWNER: bigint; + HYPESQUAD_EVENTS: bigint; + BUGHUNTER_LEVEL_1: bigint; + HOUSE_BRAVERY: bigint; + HOUSE_BRILLIANCE: bigint; + HOUSE_BALANCE: bigint; + EARLY_SUPPORTER: bigint; + TEAM_USER: bigint; + SYSTEM: bigint; + BUGHUNTER_LEVEL_2: bigint; + VERIFIED_BOT: bigint; + EARLY_VERIFIED_BOT_DEVELOPER: bigint; + }; +} diff --git a/dist/util/UserFlags.js b/dist/util/UserFlags.js new file mode 100644 index 00000000..4df3f232 --- /dev/null +++ b/dist/util/UserFlags.js @@ -0,0 +1,25 @@ +"use strict"; +// https://github.com/discordjs/discord.js/blob/master/src/util/UserFlags.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +Object.defineProperty(exports, "__esModule", { value: true }); +exports.UserFlags = void 0; +const BitField_1 = require("./BitField"); +class UserFlags extends BitField_1.BitField { +} +exports.UserFlags = UserFlags; +UserFlags.FLAGS = { + DISCORD_EMPLOYEE: 1n << 0n, + PARTNERED_SERVER_OWNER: 1n << 1n, + HYPESQUAD_EVENTS: 1n << 2n, + BUGHUNTER_LEVEL_1: 1n << 3n, + HOUSE_BRAVERY: 1n << 6n, + HOUSE_BRILLIANCE: 1n << 7n, + HOUSE_BALANCE: 1n << 8n, + EARLY_SUPPORTER: 1n << 9n, + TEAM_USER: 1n << 10n, + SYSTEM: 1n << 12n, + BUGHUNTER_LEVEL_2: 1n << 14n, + VERIFIED_BOT: 1n << 16n, + EARLY_VERIFIED_BOT_DEVELOPER: 1n << 17n, +}; +//# sourceMappingURL=UserFlags.js.map \ No newline at end of file diff --git a/dist/util/UserFlags.js.map b/dist/util/UserFlags.js.map new file mode 100644 index 00000000..997bd6da --- /dev/null +++ b/dist/util/UserFlags.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserFlags.js","sourceRoot":"","sources":["../../src/util/UserFlags.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,8DAA8D;;;AAE9D,yCAAsC;AAEtC,MAAa,SAAU,SAAQ,mBAAQ;;AAAvC,8BAgBC;AAfO,eAAK,GAAG;IACd,gBAAgB,EAAE,EAAE,IAAI,EAAE;IAC1B,sBAAsB,EAAE,EAAE,IAAI,EAAE;IAChC,gBAAgB,EAAE,EAAE,IAAI,EAAE;IAC1B,iBAAiB,EAAE,EAAE,IAAI,EAAE;IAC3B,aAAa,EAAE,EAAE,IAAI,EAAE;IACvB,gBAAgB,EAAE,EAAE,IAAI,EAAE;IAC1B,aAAa,EAAE,EAAE,IAAI,EAAE;IACvB,eAAe,EAAE,EAAE,IAAI,EAAE;IACzB,SAAS,EAAE,EAAE,IAAI,GAAG;IACpB,MAAM,EAAE,EAAE,IAAI,GAAG;IACjB,iBAAiB,EAAE,EAAE,IAAI,GAAG;IAC5B,YAAY,EAAE,EAAE,IAAI,GAAG;IACvB,4BAA4B,EAAE,EAAE,IAAI,GAAG;CACvC,CAAC"} \ No newline at end of file diff --git a/dist/checkToken.d.ts b/dist/util/checkToken.d.ts index 478d382a..478d382a 100644 --- a/dist/checkToken.d.ts +++ b/dist/util/checkToken.d.ts diff --git a/dist/checkToken.js b/dist/util/checkToken.js index 17d88178..17d88178 100644 --- a/dist/checkToken.js +++ b/dist/util/checkToken.js diff --git a/dist/util/checkToken.js.map b/dist/util/checkToken.js.map new file mode 100644 index 00000000..173dd43d --- /dev/null +++ b/dist/util/checkToken.js.map @@ -0,0 +1 @@ +{"version":3,"file":"checkToken.js","sourceRoot":"","sources":["../../src/util/checkToken.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAyC;AACzC,gEAA+B;AAC/B,sDAA8B;AAE9B,SAAgB,UAAU,CAAC,KAAa;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC/B,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,gBAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,sBAAU,EAAE,CAAC,GAAG,EAAE,OAAY,EAAE,EAAE;YAC3F,IAAI,GAAG,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,eAAe,CAAC,CAAC;YAEjD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1d501baf..5605997c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -import { checkToken } from "./checkToken"; -import Config, { DefaultOptions } from "./Config"; -import db from "./Database"; -import * as Constants from "./Constants"; +import { checkToken } from "./util/checkToken"; +import Config, { DefaultOptions } from "./util/Config"; +import db from "./util/Database"; +import * as Constants from "./util/Constants"; import { Channel } from "./models/Channel"; import { Emoji } from "./models/Emoji"; import { Guild } from "./models/Guild"; @@ -9,5 +9,24 @@ import { Invite } from "./models/Invite"; import { Member } from "./models/Member"; import { Role } from "./models/Role"; import { User } from "./models/User"; +import { EmojiSchema } from "./Schema/Emoji"; +import { ActivitySchema } from "./Schema/Activity"; +import { IdentifySchema } from "./Schema/Identify"; -export { checkToken, Config, Constants, db, DefaultOptions, Channel, Emoji, Guild, Invite, Member, Role, User }; +export { + checkToken, + Config, + Constants, + db, + DefaultOptions, + Channel, + Emoji, + Guild, + Invite, + Member, + Role, + User, + EmojiSchema, + ActivitySchema, + IdentifySchema, +}; diff --git a/src/util/BitField.ts b/src/util/BitField.ts new file mode 100644 index 00000000..17eef796 --- /dev/null +++ b/src/util/BitField.ts @@ -0,0 +1,138 @@ +"use strict"; + +// https://github.com/discordjs/discord.js/blob/master/src/util/BitField.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah + +export type BitFieldResolvable = number | BigInt | BitField | string | BitFieldResolvable[]; + +/** + * Data structure that makes it easy to interact with a bitfield. + */ +export class BitField { + public bitfield: bigint = BigInt(0); + + public static FLAGS: Record<string, bigint>; + + constructor(bits: BitFieldResolvable = 0) { + this.bitfield = BitField.resolve(bits); + } + + /** + * Checks whether the bitfield has a bit, or any of multiple bits. + */ + any(bit: BitFieldResolvable): boolean { + return (this.bitfield & BitField.resolve(bit)) !== 0n; + } + + /** + * Checks if this bitfield equals another + */ + equals(bit: BitFieldResolvable): boolean { + return this.bitfield === BitField.resolve(bit); + } + + /** + * Checks whether the bitfield has a bit, or multiple bits. + */ + has(bit: BitFieldResolvable): boolean { + if (Array.isArray(bit)) return bit.every((p) => this.has(p)); + const BIT = BitField.resolve(bit); + return (this.bitfield & BIT) === BIT; + } + + /** + * Gets all given bits that are missing from the bitfield. + */ + missing(bits: BitFieldResolvable) { + if (!Array.isArray(bits)) bits = new BitField(bits).toArray(); + return bits.filter((p) => !this.has(p)); + } + + /** + * Freezes these bits, making them immutable. + */ + freeze(): Readonly<BitField> { + return Object.freeze(this); + } + + /** + * Adds bits to these ones. + * @param {...BitFieldResolvable} [bits] Bits to add + * @returns {BitField} These bits or new BitField if the instance is frozen. + */ + add(...bits: BitFieldResolvable[]): BitField { + let total = 0n; + for (const bit of bits) { + total |= BitField.resolve(bit); + } + if (Object.isFrozen(this)) return new BitField(this.bitfield | total); + this.bitfield |= total; + return this; + } + + /** + * Removes bits from these. + * @param {...BitFieldResolvable} [bits] Bits to remove + */ + remove(...bits: BitFieldResolvable[]) { + let total = 0n; + for (const bit of bits) { + total |= BitField.resolve(bit); + } + if (Object.isFrozen(this)) return new BitField(this.bitfield & ~total); + this.bitfield &= ~total; + return this; + } + + /** + * Gets an object mapping field names to a {@link boolean} indicating whether the + * bit is available. + * @param {...*} hasParams Additional parameters for the has method, if any + */ + serialize() { + const serialized: Record<string, boolean> = {}; + for (const [flag, bit] of Object.entries(BitField.FLAGS)) serialized[flag] = this.has(bit); + return serialized; + } + + /** + * Gets an {@link Array} of bitfield names based on the bits available. + */ + toArray(): string[] { + return Object.keys(BitField.FLAGS).filter((bit) => this.has(bit)); + } + + toJSON() { + return this.bitfield; + } + + valueOf() { + return this.bitfield; + } + + *[Symbol.iterator]() { + yield* this.toArray(); + } + + /** + * Data that can be resolved to give a bitfield. This can be: + * * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS}) + * * An instance of BitField + * * An Array of BitFieldResolvable + * @typedef {number|BitField|BitFieldResolvable[]} BitFieldResolvable + */ + + /** + * Resolves bitfields to their numeric form. + * @param {BitFieldResolvable} [bit=0] - bit(s) to resolve + * @returns {number} + */ + static resolve(bit: BitFieldResolvable = 0n): bigint { + if ((typeof bit === "number" || typeof bit === "bigint") && bit >= 0n) return BigInt(bit); + if (bit instanceof BitField) return bit.bitfield; + if (Array.isArray(bit)) + return bit.map((p) => this.resolve(p)).reduce((prev, p) => BigInt(prev) | BigInt(p), 0n); + if (typeof bit === "string" && typeof this.FLAGS[bit] !== "undefined") return this.FLAGS[bit]; + throw new RangeError("BITFIELD_INVALID: " + bit); + } +} diff --git a/src/Config.ts b/src/util/Config.ts index b22e88e0..b22e88e0 100644 --- a/src/Config.ts +++ b/src/util/Config.ts diff --git a/src/Constants.ts b/src/util/Constants.ts index 808d234b..808d234b 100644 --- a/src/Constants.ts +++ b/src/util/Constants.ts diff --git a/src/Database.ts b/src/util/Database.ts index d842ac6b..d842ac6b 100644 --- a/src/Database.ts +++ b/src/util/Database.ts diff --git a/src/util/Intents.ts b/src/util/Intents.ts new file mode 100644 index 00000000..b96f6af9 --- /dev/null +++ b/src/util/Intents.ts @@ -0,0 +1,21 @@ +import { BitField } from "./BitField"; + +export class Intents extends BitField { + static FLAGS = { + GUILDS: 1n << 0n, + GUILD_MEMBERS: 1n << 1n, + GUILD_BANS: 1n << 2n, + GUILD_EMOJIS: 1n << 3n, + GUILD_INTEGRATIONS: 1n << 4n, + GUILD_WEBHOOKS: 1n << 5n, + GUILD_INVITES: 1n << 6n, + GUILD_VOICE_STATES: 1n << 7n, + GUILD_PRESENCES: 1n << 8n, + GUILD_MESSAGES: 1n << 9n, + GUILD_MESSAGE_REACTIONS: 1n << 10n, + GUILD_MESSAGE_TYPING: 1n << 11n, + DIRECT_MESSAGES: 1n << 12n, + DIRECT_MESSAGE_REACTIONS: 1n << 13n, + DIRECT_MESSAGE_TYPING: 1n << 14n, + }; +} diff --git a/src/util/MessageFlags.ts b/src/util/MessageFlags.ts new file mode 100644 index 00000000..d3e6a07a --- /dev/null +++ b/src/util/MessageFlags.ts @@ -0,0 +1,14 @@ +// https://github.com/discordjs/discord.js/blob/master/src/util/MessageFlags.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah + +import { BitField } from "./BitField"; + +export class MessageFlags extends BitField { + static FLAGS = { + CROSSPOSTED: 1n << 0n, + IS_CROSSPOST: 1n << 1n, + SUPPRESS_EMBEDS: 1n << 2n, + SOURCE_MESSAGE_DELETED: 1n << 3n, + URGENT: 1n << 4n, + }; +} diff --git a/src/util/Permissions.ts b/src/util/Permissions.ts new file mode 100644 index 00000000..f076e0c2 --- /dev/null +++ b/src/util/Permissions.ts @@ -0,0 +1,56 @@ +// https://github.com/discordjs/discord.js/blob/master/src/util/Permissions.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah + +import { BitField } from "./BitField"; + +export type PermissionResolvable = string | number | Permissions | PermissionResolvable[]; + +export class Permissions extends BitField { + static FLAGS = { + CREATE_INSTANT_INVITE: 1n << 0n, + KICK_MEMBERS: 1n << 1n, + BAN_MEMBERS: 1n << 2n, + ADMINISTRATOR: 1n << 3n, + MANAGE_CHANNELS: 1n << 4n, + MANAGE_GUILD: 1n << 5n, + ADD_REACTIONS: 1n << 6n, + VIEW_AUDIT_LOG: 1n << 7n, + PRIORITY_SPEAKER: 1n << 8n, + STREAM: 1n << 9n, + VIEW_CHANNEL: 1n << 10n, + SEND_MESSAGES: 1n << 11n, + SEND_TTS_MESSAGES: 1n << 12n, + MANAGE_MESSAGES: 1n << 13n, + EMBED_LINKS: 1n << 14n, + ATTACH_FILES: 1n << 15n, + READ_MESSAGE_HISTORY: 1n << 16n, + MENTION_EVERYONE: 1n << 17n, + USE_EXTERNAL_EMOJIS: 1n << 18n, + VIEW_GUILD_INSIGHTS: 1n << 19n, + CONNECT: 1n << 20n, + SPEAK: 1n << 21n, + MUTE_MEMBERS: 1n << 22n, + DEAFEN_MEMBERS: 1n << 23n, + MOVE_MEMBERS: 1n << 24n, + USE_VAD: 1n << 25n, + CHANGE_NICKNAME: 1n << 26n, + MANAGE_NICKNAMES: 1n << 27n, + MANAGE_ROLES: 1n << 28n, + MANAGE_WEBHOOKS: 1n << 29n, + MANAGE_EMOJIS: 1n << 30n, + }; + + any(permission: PermissionResolvable, checkAdmin = true) { + return (checkAdmin && super.has(Permissions.FLAGS.ADMINISTRATOR)) || super.any(permission); + } + + /** + * Checks whether the bitfield has a permission, or multiple permissions. + * @param {PermissionResolvable} permission Permission(s) to check for + * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override + * @returns {boolean} + */ + has(permission: PermissionResolvable, checkAdmin = true) { + return (checkAdmin && super.has(Permissions.FLAGS.ADMINISTRATOR)) || super.has(permission); + } +} diff --git a/src/util/Snowflake.ts b/src/util/Snowflake.ts new file mode 100644 index 00000000..9e94bbd9 --- /dev/null +++ b/src/util/Snowflake.ts @@ -0,0 +1,126 @@ +// @ts-nocheck + +// https://github.com/discordjs/discord.js/blob/master/src/util/Snowflake.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah +"use strict"; + +// Discord epoch (2015-01-01T00:00:00.000Z) + +/** + * A container for useful snowflake-related methods. + */ +export class Snowflake { + static readonly EPOCH = 1420070400000; + static INCREMENT = 0n; // max 4095 + static processId = 0n; // max 31 + static workerId = 0n; // max 31 + + constructor() { + throw new Error(`The ${this.constructor.name} class may not be instantiated.`); + } + + /** + * A Twitter snowflake, except the epoch is 2015-01-01T00:00:00.000Z + * ``` + * If we have a snowflake '266241948824764416' we can represent it as binary: + * + * 64 22 17 12 0 + * 000000111011000111100001101001000101000000 00001 00000 000000000000 + * number of ms since Discord epoch worker pid increment + * ``` + * @typedef {string} Snowflake + */ + + /** + * Transforms a snowflake from a decimal string to a bit string. + * @param {Snowflake} num Snowflake to be transformed + * @returns {string} + * @private + */ + static idToBinary(num) { + let bin = ""; + let high = parseInt(num.slice(0, -10)) || 0; + let low = parseInt(num.slice(-10)); + while (low > 0 || high > 0) { + bin = String(low & 1) + bin; + low = Math.floor(low / 2); + if (high > 0) { + low += 5000000000 * (high % 2); + high = Math.floor(high / 2); + } + } + return bin; + } + + /** + * Transforms a snowflake from a bit string to a decimal string. + * @param {string} num Bit string to be transformed + * @returns {Snowflake} + * @private + */ + static binaryToID(num) { + let dec = ""; + + while (num.length > 50) { + const high = parseInt(num.slice(0, -32), 2); + const low = parseInt((high % 10).toString(2) + num.slice(-32), 2); + + dec = (low % 10).toString() + dec; + num = + Math.floor(high / 10).toString(2) + + Math.floor(low / 10) + .toString(2) + .padStart(32, "0"); + } + + num = parseInt(num, 2); + while (num > 0) { + dec = (num % 10).toString() + dec; + num = Math.floor(num / 10); + } + + return dec; + } + + static generate() { + var time = BigInt(Date.now() - Snowflake.EPOCH) << 22n; + var worker = Snowflake.workerId << 17n; + var process = Snowflake.processId << 12n; + var increment = Snowflake.INCREMENT++; + return time | worker | process | increment; + } + + /** + * A deconstructed snowflake. + * @typedef {Object} DeconstructedSnowflake + * @property {number} timestamp Timestamp the snowflake was created + * @property {Date} date Date the snowflake was created + * @property {number} workerID Worker ID in the snowflake + * @property {number} processID Process ID in the snowflake + * @property {number} increment Increment in the snowflake + * @property {string} binary Binary representation of the snowflake + */ + + /** + * Deconstructs a Discord snowflake. + * @param {Snowflake} snowflake Snowflake to deconstruct + * @returns {DeconstructedSnowflake} Deconstructed snowflake + */ + static deconstruct(snowflake) { + const BINARY = Snowflake.idToBinary(snowflake).toString(2).padStart(64, "0"); + const res = { + timestamp: parseInt(BINARY.substring(0, 42), 2) + EPOCH, + workerID: parseInt(BINARY.substring(42, 47), 2), + processID: parseInt(BINARY.substring(47, 52), 2), + increment: parseInt(BINARY.substring(52, 64), 2), + binary: BINARY, + }; + Object.defineProperty(res, "date", { + get: function get() { + return new Date(this.timestamp); + }, + enumerable: true, + }); + return res; + } +} diff --git a/src/util/String.ts b/src/util/String.ts new file mode 100644 index 00000000..afbfc1e6 --- /dev/null +++ b/src/util/String.ts @@ -0,0 +1,6 @@ +export const DOUBLE_WHITE_SPACE = /\s\s+/g; +export const SPECIAL_CHAR = /[@#`:\r\n\t\f\v\p{C}]/gu; + +export function trimSpecial(str: string) { + return str.replace(SPECIAL_CHAR, "").replace(DOUBLE_WHITE_SPACE, " ").trim(); +} diff --git a/src/util/UserFlags.ts b/src/util/UserFlags.ts new file mode 100644 index 00000000..6e532f93 --- /dev/null +++ b/src/util/UserFlags.ts @@ -0,0 +1,22 @@ +// https://github.com/discordjs/discord.js/blob/master/src/util/UserFlags.js +// Apache License Version 2.0 Copyright 2015 - 2021 Amish Shah + +import { BitField } from "./BitField"; + +export class UserFlags extends BitField { + static FLAGS = { + DISCORD_EMPLOYEE: 1n << 0n, + PARTNERED_SERVER_OWNER: 1n << 1n, + HYPESQUAD_EVENTS: 1n << 2n, + BUGHUNTER_LEVEL_1: 1n << 3n, + HOUSE_BRAVERY: 1n << 6n, + HOUSE_BRILLIANCE: 1n << 7n, + HOUSE_BALANCE: 1n << 8n, + EARLY_SUPPORTER: 1n << 9n, + TEAM_USER: 1n << 10n, + SYSTEM: 1n << 12n, + BUGHUNTER_LEVEL_2: 1n << 14n, + VERIFIED_BOT: 1n << 16n, + EARLY_VERIFIED_BOT_DEVELOPER: 1n << 17n, + }; +} diff --git a/src/checkToken.ts b/src/util/checkToken.ts index 96c7806a..96c7806a 100644 --- a/src/checkToken.ts +++ b/src/util/checkToken.ts |