diff options
Diffstat (limited to 'dist/util')
33 files changed, 685 insertions, 0 deletions
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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GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,EAAE;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/util/Config.d.ts b/dist/util/Config.d.ts new file mode 100644 index 00000000..2ab792f5 --- /dev/null +++ b/dist/util/Config.d.ts @@ -0,0 +1,13 @@ +import "missing-native-js-functions"; +declare const _default: { + init: (opts?: DefaultOptions) => Promise<void>; + getAll: () => DefaultOptions; + setAll: (val: any) => any; +}; +export default _default; +export interface DefaultOptions { + api?: any; + gateway?: any; + voice?: any; +} +export declare const DefaultOptions: DefaultOptions; diff --git a/dist/util/Config.js b/dist/util/Config.js new file mode 100644 index 00000000..948f09d6 --- /dev/null +++ b/dist/util/Config.js @@ -0,0 +1,28 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DefaultOptions = void 0; +require("missing-native-js-functions"); +const Database_1 = __importDefault(require("./Database")); +var Config; +exports.default = { + init: async function init(opts = exports.DefaultOptions) { + Config = Database_1.default.data.config({}).cache(); + await Config.init(); + await Config.set(opts.merge(Config.cache || {})); + }, + getAll: function get() { + return Config.get(); + }, + setAll: function set(val) { + return Config.set(val); + }, +}; +exports.DefaultOptions = { + api: {}, + gateway: {}, + voice: {}, +}; +//# sourceMappingURL=Config.js.map \ No newline at end of file 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/util/Constants.d.ts b/dist/util/Constants.d.ts new file mode 100644 index 00000000..ecceb4e6 --- /dev/null +++ b/dist/util/Constants.d.ts @@ -0,0 +1,2 @@ +import { VerifyOptions } from "jsonwebtoken"; +export declare const JWTOptions: VerifyOptions; diff --git a/dist/util/Constants.js b/dist/util/Constants.js new file mode 100644 index 00000000..d65f8185 --- /dev/null +++ b/dist/util/Constants.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.JWTOptions = void 0; +exports.JWTOptions = { algorithms: ["HS256"] }; +//# sourceMappingURL=Constants.js.map \ No newline at end of file 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/util/Database.d.ts b/dist/util/Database.d.ts new file mode 100644 index 00000000..1a45ea78 --- /dev/null +++ b/dist/util/Database.d.ts @@ -0,0 +1,3 @@ +import { MongoDatabase } from "lambert-db"; +declare const db: MongoDatabase; +export default db; diff --git a/dist/util/Database.js b/dist/util/Database.js new file mode 100644 index 00000000..9fe58f0a --- /dev/null +++ b/dist/util/Database.js @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const lambert_db_1 = require("lambert-db"); +// TODO: load url from config +const db = new lambert_db_1.MongoDatabase("mongodb://127.0.0.1:27017/lambert?readPreference=secondaryPreferred"); +exports.default = db; +//# sourceMappingURL=Database.js.map \ No newline at end of file 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":[],"mappings":";AAAA,8EAA8E;AAC9E,8DAA8D;;;AAE9D,yCAAsC;AAItC,MAAa,WAAY,SAAQ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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;AAC9D,YAAY,CAAC;;;AAEb,2CAA2C;AAE3C;;GAEG;AACH,MAAa,SAAS;IAMrB;QAC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G,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/util/checkToken.d.ts b/dist/util/checkToken.d.ts new file mode 100644 index 00000000..478d382a --- /dev/null +++ b/dist/util/checkToken.d.ts @@ -0,0 +1 @@ +export declare function checkToken(token: string): Promise<unknown>; diff --git a/dist/util/checkToken.js b/dist/util/checkToken.js new file mode 100644 index 00000000..17d88178 --- /dev/null +++ b/dist/util/checkToken.js @@ -0,0 +1,20 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.checkToken = void 0; +const Constants_1 = require("./Constants"); +const jsonwebtoken_1 = __importDefault(require("jsonwebtoken")); +const Config_1 = __importDefault(require("./Config")); +function checkToken(token) { + return new Promise((res, rej) => { + jsonwebtoken_1.default.verify(token, Config_1.default.getAll().api.security.jwtSecret, Constants_1.JWTOptions, (err, decoded) => { + if (err || !decoded) + return rej("Invalid Token"); + return res(decoded); + }); + }); +} +exports.checkToken = checkToken; +//# sourceMappingURL=checkToken.js.map \ No newline at end of file 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 |