@chatsift/discord-utils 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (C) 2021 didinele
2
+
3
+ This program is free software: you can redistribute it and/or modify
4
+ it under the terms of the GNU Affero General Public License as
5
+ published by the Free Software Foundation, either version 3 of the
6
+ License, or (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU Affero General Public License for more details.
12
+
13
+ You should have received a copy of the GNU Affero General Public License
14
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # `@chatsift/discord-utils`
2
+
3
+ [![GitHub](https://img.shields.io/badge/License-GNU%20AGPLv3-yellow.svg)](https://github.com/ChatSift/packages/blob/main/LICENSE)
4
+ [![npm](https://img.shields.io/npm/v/@chatsift/discord-utils?color=crimson&logo=npm)](https://www.npmjs.com/package/@chatsift/discord-utils)
5
+ [![TypeScript](https://github.com/ChatSift/packages/actions/workflows/quality.yml/badge.svg)](https://github.com/ChatSift/packages/actions/workflows/quality.yml)
6
+
7
+ Niche utilities for working with Discord's API
8
+
9
+ ## Installation
10
+
11
+ - `npm install @chatsift/discord-utils`
12
+ - `pnpm install @chatsift/discord-utils`
13
+ - `yarn add @chatsift/discord-utils`
14
+
15
+ ## Contributing
16
+
17
+ Please see the main [README.md](https://github.com/ChatSift/packages) for info on how to contribute to this package or the other `@chatsift` packages.
18
+
19
+ ## LICENSE
20
+
21
+ This project is licensed under the GNU AGPLv3 license.
22
+
23
+ It should, however, be noted that some packages are forks of other open source projects, and are therefore, sub-licensed.
package/dist/embed.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateEmbed = exports.ellipsis = exports.addFields = exports.MESSAGE_LIMITS = void 0;
4
+ exports.MESSAGE_LIMITS = {
5
+ CONTENT: 4000,
6
+ EMBED_COUNT: 10,
7
+ EMBEDS: {
8
+ TITLE: 256,
9
+ DESCRIPTION: 4096,
10
+ FOOTER: 2048,
11
+ AUTHOR: 256,
12
+ FIELD_COUNT: 25,
13
+ FIELDS: {
14
+ NAME: 256,
15
+ VALUE: 1024,
16
+ },
17
+ },
18
+ };
19
+ function addFields(embed, ...fields) {
20
+ (embed.fields ?? (embed.fields = [])).push(...fields);
21
+ return embed;
22
+ }
23
+ exports.addFields = addFields;
24
+ function ellipsis(text, total) {
25
+ if (text.length <= total) {
26
+ return text;
27
+ }
28
+ const keep = total - 3;
29
+ if (keep < 1) {
30
+ return text.slice(0, total);
31
+ }
32
+ return `${text.slice(0, keep)}...`;
33
+ }
34
+ exports.ellipsis = ellipsis;
35
+ function truncateEmbed(embed) {
36
+ return {
37
+ ...embed,
38
+ description: embed.description ? ellipsis(embed.description, exports.MESSAGE_LIMITS.EMBEDS.DESCRIPTION) : undefined,
39
+ title: embed.title ? ellipsis(embed.title, exports.MESSAGE_LIMITS.EMBEDS.TITLE) : undefined,
40
+ author: embed.author
41
+ ? {
42
+ ...embed.author,
43
+ name: ellipsis(embed.author.name, exports.MESSAGE_LIMITS.EMBEDS.AUTHOR),
44
+ }
45
+ : undefined,
46
+ footer: embed.footer
47
+ ? {
48
+ ...embed.footer,
49
+ text: ellipsis(embed.footer.text, exports.MESSAGE_LIMITS.EMBEDS.FOOTER),
50
+ }
51
+ : undefined,
52
+ fields: embed.fields
53
+ ? embed.fields
54
+ .map((field) => ({
55
+ name: ellipsis(field.name, exports.MESSAGE_LIMITS.EMBEDS.FIELDS.NAME),
56
+ value: ellipsis(field.value, exports.MESSAGE_LIMITS.EMBEDS.FIELDS.VALUE),
57
+ }))
58
+ .slice(0, exports.MESSAGE_LIMITS.EMBEDS.FIELD_COUNT)
59
+ : [],
60
+ };
61
+ }
62
+ exports.truncateEmbed = truncateEmbed;
63
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.js","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":";;;AAKa,QAAA,cAAc,GAAG;IAI7B,OAAO,EAAE,IAAI;IAIb,WAAW,EAAE,EAAE;IAIf,MAAM,EAAE;QAIP,KAAK,EAAE,GAAG;QAIV,WAAW,EAAE,IAAI;QAIjB,MAAM,EAAE,IAAI;QAIZ,MAAM,EAAE,GAAG;QAIX,WAAW,EAAE,EAAE;QAIf,MAAM,EAAE;YAIP,IAAI,EAAE,GAAG;YAIT,KAAK,EAAE,IAAI;SACX;KACD;CACQ,CAAC;AAOX,SAAgB,SAAS,CAAC,KAAe,EAAE,GAAG,MAAuB;IACpE,CAAC,KAAK,CAAC,MAAM,KAAZ,KAAK,CAAC,MAAM,GAAK,EAAE,EAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACd,CAAC;AAHD,8BAGC;AAOD,SAAgB,QAAQ,CAAC,IAAY,EAAE,KAAa;IACnD,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,EAAE;QACzB,OAAO,IAAI,CAAC;KACZ;IAED,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,IAAI,IAAI,GAAG,CAAC,EAAE;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;KAC5B;IAED,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;AACpC,CAAC;AAXD,4BAWC;AAMD,SAAgB,aAAa,CAAC,KAAe;IAC5C,OAAO;QACN,GAAG,KAAK;QACR,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,sBAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3G,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;QACnF,MAAM,EAAE,KAAK,CAAC,MAAM;YACnB,CAAC,CAAC;gBACA,GAAG,KAAK,CAAC,MAAM;gBACf,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,CAAC,MAAM,CAAC;aAC9D;YACH,CAAC,CAAC,SAAS;QACZ,MAAM,EAAE,KAAK,CAAC,MAAM;YACnB,CAAC,CAAC;gBACA,GAAG,KAAK,CAAC,MAAM;gBACf,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,CAAC,MAAM,CAAC;aAC9D;YACH,CAAC,CAAC,SAAS;QACZ,MAAM,EAAE,KAAK,CAAC,MAAM;YACnB,CAAC,CAAC,KAAK,CAAC,MAAM;iBACX,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAChB,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,sBAAc,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC7D,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,sBAAc,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;aAChE,CAAC,CAAC;iBACF,KAAK,CAAC,CAAC,EAAE,sBAAc,CAAC,MAAM,CAAC,WAAW,CAAC;YAC9C,CAAC,CAAC,EAAE;KACL,CAAC;AACH,CAAC;AA1BD,sCA0BC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./embed"), exports);
5
+ (0, tslib_1.__exportStar)(require("./sortChannels"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAwB;AACxB,8DAA+B"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortChannels = void 0;
4
+ const utils_1 = require("@chatsift/utils");
5
+ require("discord-api-types/v9");
6
+ function sortChannels(unsorted) {
7
+ const grouped = (0, utils_1.groupBy)(unsorted, (c) => c.parent_id ?? 'top');
8
+ const sortedTopLevel = grouped.top
9
+ ?.filter((channel) => !channel.parent_id)
10
+ .sort((a, b) => {
11
+ if (a.type === 0 && b.type === 4) {
12
+ return -1;
13
+ }
14
+ if (a.type === 4 && b.type === 0) {
15
+ return 1;
16
+ }
17
+ return a.position - b.position;
18
+ });
19
+ const channels = [];
20
+ for (const top of sortedTopLevel ?? []) {
21
+ channels.push(top);
22
+ if (top.type === 4) {
23
+ channels.push(...(grouped[top.id] ?? []).sort((a, b) => a.position - b.position));
24
+ }
25
+ }
26
+ return channels.length ? channels : unsorted.sort((a, b) => a.position - b.position);
27
+ }
28
+ exports.sortChannels = sortChannels;
29
+ //# sourceMappingURL=sortChannels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortChannels.js","sourceRoot":"","sources":["../src/sortChannels.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,gCAA+D;AAK/D,SAAgB,YAAY,CAAC,QAAsB;IAElD,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,CAAC;IAG/D,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG;QACjC,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;SACxC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC,IAAI,MAA0B,IAAI,CAAC,CAAC,IAAI,MAA8B,EAAE;YAC7E,OAAO,CAAC,CAAC,CAAC;SACV;QAED,IAAI,CAAC,CAAC,IAAI,MAA8B,IAAI,CAAC,CAAC,IAAI,MAA0B,EAAE;YAC7E,OAAO,CAAC,CAAC;SACT;QAED,OAAO,CAAC,CAAC,QAAS,GAAG,CAAC,CAAC,QAAS,CAAC;IAClC,CAAC,CAAC,CAAC;IAEJ,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,cAAc,IAAI,EAAE,EAAE;QACvC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnB,IAAI,GAAG,CAAC,IAAI,MAA8B,EAAE;YAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAS,GAAG,CAAC,CAAC,QAAS,CAAC,CAAC,CAAC;SACpF;KACD;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAS,GAAG,CAAC,CAAC,QAAS,CAAC,CAAC;AACxF,CAAC;AA7BD,oCA6BC"}
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@4.5.4/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/.pnpm/tslib@2.3.1/node_modules/tslib/tslib.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/globals.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/permissions.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/emoji.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/internals.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/shared.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/base.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/string.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/integer.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/boolean.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/user.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/channel.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/role.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/mentionable.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/number.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommand.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/_chatInput/subcommandGroup.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/chatInput.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/contextMenu.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/_applicationCommands/permissions.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/applicationCommands.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/responses.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/base.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/messageComponents.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/ping.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/_interactions/autocomplete.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/interactions.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/sticker.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/channel.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/gateway.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/stageInstance.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/voice.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/guildScheduledEvent.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/guild.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/user.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/teams.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/application.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/webhook.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/auditLog.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/invite.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/oauth2.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/common.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/auditLog.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/utils/internals.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/channel.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/emoji.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/gateway.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/guild.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/guildScheduledEvent.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/webhook.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/interactions.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/invite.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/oauth2.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/stageInstance.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/sticker.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/template.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/user.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/voice.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rest/v9/index.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/template.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/payloads/v9/index.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/gateway/common.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/gateway/v9.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/rpc/v9.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/utils/v9.d.ts","../../../node_modules/.pnpm/discord-api-types@0.26.1/node_modules/discord-api-types/v9.d.ts","../src/embed.ts","../../utils/types/index.d.ts","../src/sortChannels.ts","../src/index.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/assert.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/globals.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/buffer.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/child_process.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/cluster.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/console.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/constants.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/crypto.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/dgram.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/dns.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/domain.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/fs.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/http.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/http2.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/https.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/inspector.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/module.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/net.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/os.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/path.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/process.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/punycode.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/querystring.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/readline.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/repl.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/stream.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/stream/web.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/timers.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/tls.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/trace_events.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/tty.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/url.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/util.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/v8.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/vm.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/wasi.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/zlib.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/globals.global.d.ts","../../../node_modules/.pnpm/@types+node@16.11.19/node_modules/@types/node/index.d.ts","../../../node_modules/.pnpm/@babel+types@7.16.7/node_modules/@babel/types/lib/index.d.ts","../../../node_modules/.pnpm/@types+babel__generator@7.6.4/node_modules/@types/babel__generator/index.d.ts","../../../node_modules/.pnpm/@babel+parser@7.16.7/node_modules/@babel/parser/typings/babel-parser.d.ts","../../../node_modules/.pnpm/@types+babel__template@7.4.1/node_modules/@types/babel__template/index.d.ts","../../../node_modules/.pnpm/@types+babel__traverse@7.14.2/node_modules/@types/babel__traverse/index.d.ts","../../../node_modules/.pnpm/@types+babel__core@7.1.18/node_modules/@types/babel__core/index.d.ts","../../../node_modules/.pnpm/@types+cookie@0.4.1/node_modules/@types/cookie/index.d.ts","../../../node_modules/.pnpm/@types+eslint-visitor-keys@1.0.0/node_modules/@types/eslint-visitor-keys/index.d.ts","../../../node_modules/.pnpm/@types+graceful-fs@4.1.5/node_modules/@types/graceful-fs/index.d.ts","../../../node_modules/.pnpm/@types+istanbul-lib-coverage@2.0.4/node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../node_modules/.pnpm/@types+istanbul-lib-report@3.0.0/node_modules/@types/istanbul-lib-report/index.d.ts","../../../node_modules/.pnpm/@types+istanbul-reports@3.0.1/node_modules/@types/istanbul-reports/index.d.ts","../../../node_modules/.pnpm/jest-diff@26.6.2/node_modules/jest-diff/build/cleanupSemantic.d.ts","../../../node_modules/.pnpm/jest-diff@26.6.2/node_modules/jest-diff/build/types.d.ts","../../../node_modules/.pnpm/jest-diff@26.6.2/node_modules/jest-diff/build/diffLines.d.ts","../../../node_modules/.pnpm/jest-diff@26.6.2/node_modules/jest-diff/build/printDiffs.d.ts","../../../node_modules/.pnpm/jest-diff@26.6.2/node_modules/jest-diff/build/index.d.ts","../../../node_modules/.pnpm/pretty-format@26.6.2/node_modules/pretty-format/build/types.d.ts","../../../node_modules/.pnpm/pretty-format@26.6.2/node_modules/pretty-format/build/index.d.ts","../../../node_modules/.pnpm/@types+jest@26.0.24/node_modules/@types/jest/index.d.ts","../../../node_modules/.pnpm/@types+json-schema@7.0.9/node_modules/@types/json-schema/index.d.ts","../../../node_modules/.pnpm/form-data@3.0.1/node_modules/form-data/index.d.ts","../../../node_modules/.pnpm/@types+node-fetch@2.5.12/node_modules/@types/node-fetch/externals.d.ts","../../../node_modules/.pnpm/@types+node-fetch@2.5.12/node_modules/@types/node-fetch/index.d.ts","../../../node_modules/.pnpm/@types+normalize-package-data@2.4.1/node_modules/@types/normalize-package-data/index.d.ts","../../../node_modules/.pnpm/@types+parse-json@4.0.0/node_modules/@types/parse-json/index.d.ts","../../../node_modules/.pnpm/@types+prettier@2.4.2/node_modules/@types/prettier/index.d.ts","../../../node_modules/.pnpm/@types+stack-utils@2.0.1/node_modules/@types/stack-utils/index.d.ts","../../../node_modules/.pnpm/@types+yargs-parser@20.2.1/node_modules/@types/yargs-parser/index.d.ts","../../../node_modules/.pnpm/@types+yargs@15.0.14/node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"89f78430e422a0f06d13019d60d5a45b37ec2d28e67eb647f73b1b0d19a46b72","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"e8c9f4e445a489991ca1a4232667de3ac36b07ba75ea335971fbeacf2d26fe67","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","eabab93ca9a786745af72195153280e883d8e36df9829ecf8b2f539824d042be","d3ed0bdc7460d95a90732872f2861a60f064318b8bad8ad4432d1c04e825c3e4","681f35c141c7a6201d5ffc038fbc28e46fb7a8702fc52b29d2d2dc7ca03328c2","cdb9451988aef334a797bc31eed3235d7b471a6e013bd2ccc92fbf89a535f4d7","8cedbf274baeb7b06233ee4adce9da566fc4c496d88b3fc6dbb58e27b7b90f58","f74b7a54220bc565c738b824fdc2f063ca727001ee9f332d5c399bc59071611f","c7f940a988e13a3948197c3448e896087f598a5a4c7814030d1e54332043d1af","55518514e8bff9cebd363d735c3e85ba1c6f7588c9f320dbc1d565086ef2fc48","9f7e239f4945672307c7d4403aa22bfe3d03f438fa072d7f158095f7df724e9f","7c5073d67f4f2546f368fe635573cfe6de977ed82318d01be15cee4c76c81199","7428869b608e55da6957d000ef9af727ec7424ebef7d2accc3901287c588b5e5","ddef4fa1fd835adfae5660c6c98b24b602fbb65db1e2570fa5d9e947ad5cb17f","e7fb389e0c13e2120c9a8c824ddfabe18e56c316e53e66072e8d86e0610791e6","1b1bd699dfd3c316e64d0d40ce6e35265c24d25a18f6a4505904a0cc21f1ff67","8441a2b8098131edeec9b5092ae81903938a8c3ec8871de2502decff35ccda50","7dbf615f4a2003faa46d93052c7abaa635aa541e266090b0b2350f40f3ae3242","9575d7cfbd601fda04531bb7a10dcc68529554c484e93e5f85a39e2101988612","d91ebb09c2ae0cf320b66c42db3811e4cc8a8ebfc63c3b1e0ee0085cf1fa51ef","b044fccf84b0f5c7cd8a1800a2ef0a7b740c062245823ce009265f4db3942623","97e85df57e051301f940bad38a1e521bf4bd5e98da75554223cd30b0126b29f3","7c717290cb697d86874835037c8aab715d9477e7377c2a53198f2093c0addb2a","e285d39bd2590bf6e30dc326b513ffbc6e7ca2d67fcd94f2761e7f54cfa46dfc","d0d504c82b2a5d2bf48b951a5502ac7284ed974e3249a4fd1c795522c11d9a0d","168eef670afa53e786ccb6afbf3cb78457ff6cc90064e80f0bc5da96cffda665","5651b6955a71b3733260dcf5f7d90f9d648d70b0c1fe24ff8bdcda589f60cbff","36ef474db058911c62a48e6137965cb1dbbdef6a5c97b6887795984d9ee53afb","f416e94790298bdfb37bdc8adb84239880af9224fb1c8513386a6e380aee805d","22af4d26bffe0e8c6c84e9d0d524d9cf770475365ca1c87467dbadd472c90b87","79ce4bd3aabe9f6232bbf25eeaad9994ca94f416139224ebb01085e5ec8290af","fef0f40e32a9e21e58a8ed60607caa0037e55c4c6fe3c842a5c3bd54888f9afa","aebf66a3565c822b77a0c63280f3b07ef3040c985cfea54ad60e91f93b171ab9","aaed09d856decdec134bd8c26a6cbf7d2584bf80c9e89c44c97e267b394b471b","6e18d45952d633c80a1d3a18171aa4a99d3dd0a1615ac2fd88fa93ec01d18ae8","ea4676f9da6673aa1835921f4d9ade3c9fa36a874633b9b90c3dbcde901da3a2","d110ef7cb005b60066855a3d0613dcb33e78c88ab48f1a94be49d8670d9b5496","f3eced93d63b305dd25c3bc0f550921dda3e40acab73276a929e9d01afe44ffe","236a8048bc96944178f7459a0533cc3002e4f923a5f9bca88834d0d2a9290483","d5a60529c38f737d3567074f9a4ec7e4da7759df10912cad6f3d8bdbe662e9a1","4334f5fea672cd97484fa8ef470e5656d0f1bfcc48af553b7f1565bd46f96497","22b6cddb5322bfe32a890fdd3f3a06264d1539f892e3a4f6dbf6f3aa8135883f","3da82fc6ac4649060e524e8bce0b8ba8fe9b17716961f859d30df03734841211","f29e54511f37f6b0c8fa2825db6498afb9ffe2ab828ea6e692b68529cdba7482","437b16e89921dc25ab6313e6685d08c6de6a7df806ff0ffd83596116cb69a0ca","6028cfd2497f620b82b9e75502d3ae11dbb22b87286e2f21859cd5818f75ce9e","543771e77174eda3343f06a7edd0af8b044d83ac8b5e73ec7fbe576fa090d4a2","3134088754c10c988c58ad5cc63b6746e390d72c14a89d73a56100656925b532","95f782b13666a491781b662afacf326f2733f44d8e69a3302ef6e8f30e5784e4","b26659455eb3489593a2bc52a3db4ba638ac626b3a6b2c487c60616846eb33bb","3eba383986313232108bd804db31b71f60367732f6bb08b0a595089efb8f2652","0421ecd58522337c4659fd264eaa659281f494811728c6c9cb873f027719e9d8","5997a6356ec3bca0376b56cd4273adff367934c192e80acb9ca84b2a141727be","fa51e795c197f47e1637261e029249887cd04c36ca9b811d08af8604d8691dc8","d49cc486d093e5e8ae1c26ab9ef34ff6aa3b370173b72a8c7f26d5405abbd896","eb01a7a34a9801b025e68ffcfeba35878026ef0aed36c5d5c1167c27509e68ba","60935703b458c8c407471d3a87112e7733cae17198cf1fa254020c0ffed85b1d","eeabb4e164fe8fbc0caf6afec094230498edc84e7239a3ad38b9c9255b36f80b","e6c450d02573f08e0b7253cbfadd93855c2353344e38b0681c06d44c3caaa6a3","cae3abdc49bdbbefe16879b9e0e08a7c1c8cd2864b7d64645dff1112901145ba","301c604c264389f8f6b4911830488dade60db491489c53b8e7f782616e2b9385","37f92d1fb75f356fcb796bd0dcb65a8a49c93676c1804c13649a690abdd6f2a3","bad7ce18863ea540ea1b6a908f14bb407eeb8ba629f5daed791740cf6512c10e","bc75aa14918b32aab1b84c9f036e0d0636a67a34d87a5c9b8663a43434cb46bf","d9de6be7ea546933d744a8f6c222ce18f840a68cddc8eac8c5a4af37fbc6d802","06511a15f80ee05b40d987fe15532069416e8276d6cd0b0112e6bf058c975ffe","880787c9fb1ef2e540e1f3316ef53d3fb3ce65fc286afc7a060532e8996d475d","94371ffc473f9a6a1feb7d14841a21e2b580906814e6742d88716399b1e1e2d7","8af607a21b60e83a9e3b4b1a76847af380fefd5c649cccdcc2eb5f7d3a9bb1cb","14a8cc94275e349f94ae47b7fce45183c9c592a9e88ab3755eaab591c5d519ef","72334ba05b50cfff1539839af0cf63835340abea0c70cf210ef18c0c2fdfbe05","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"92d63add669d18ebc349efbacd88966d6f2ccdddfb1b880b2db98ae3aa7bf7c4","affectsGlobalScope":true},"ccc94049a9841fe47abe5baef6be9a38fc6228807974ae675fb15dc22531b4be",{"version":"9acfe4d1ff027015151ce81d60797b04b52bffe97ad8310bb0ec2e8fd61e1303","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","2f520601649a893e6a49a8851ebfcf4be8ce090dc1281c2a08a871cb04e8251f","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","2b8c764f856a1dd0a9a2bf23e5efddbff157de8138b0754010be561ae5fcaa90","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","b9b963043551b034abd9e7c6d859f7a81d99479fde938d983114d167d0644a78","160cc6e3d06938535bc887754afe5798c22d81ce83a9792ebfe2371a70f2ffc2","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","a458dc78104cc80048ac24fdc02fe6dce254838094c2f25641b3f954d9721241",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"eecd493fc62c4dba3d988e2d7dff63299bf12ab49f5c9021dfef8dcc1ff2089e","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","945a841f9a591197154c85386bc5a1467d42d325104bb36db51bc566bbb240be","10c39ce1df102994b47d4bc0c71aa9a6aea76f4651a5ec51914431f50bc883a1",{"version":"8207e7e6db9aa5fc7e61c8f17ba74cf9c115d26f51f91ee93f790815a7ea9dfb","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","d7838022c7dab596357a9604b9c6adffe37dc34085ce0779c958ce9545bd7139","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"a7971f9fb2a32ec7788ec6cda9d7a33c02023dfe9a62db2030ad1359649d8050","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"b42b47e17b8ece2424ae8039feb944c2e3ba4b262986aebd582e51efbdca93dc","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4","d88ecca73348e7c337541c4b8b60a50aca5e87384f6b8a422fc6603c637e4c21","badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1cdb8f094b969dcc183745dc88404e2d8fcf2a858c6e7cc2441011476573238e","d5d7b68f5369a210c235cd65458369888f8b839192d088c964f21cab3ac954db","cc957354aa3c94c9961ebf46282cfde1e81d107fc5785a61f62c67f1dd3ac2eb","64b867c61effed7b5bc0cc06b3d8eac23b067a3fba581fc7d3c292fa593e6a45","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","3b043cf9a81854a72963fdb57d1884fc4da1cf5be69b5e0a4c5b751e58cb6d88","dd5647a9ccccb2b074dca8a02b00948ac293091ebe73fdf2e6e98f718819f669","117ffeecf6c55e25b6446f449ad079029b5e7317399b0a693858faaaea5ca73e","725d9be2fd48440256f4deb00649adffdbc5ecd282b09e89d4e200663792c34c","3ebae8c00411116a66fca65b08228ea0cf0b72724701f9b854442100aab55aba","8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","d8aab31ba8e618cc3eea10b0945de81cb93b7e8150a013a482332263b9305322","69da61a7b5093dac77fa3bec8be95dcf9a74c95a0e9161edb98bb24e30e439d2","561eca7a381b96d6ccac6e4061e6d2ae53f5bc44203f3fd9f5b26864c32ae6e9","62ea38627e3ebab429f7616812a9394d327c2bc271003dfba985de9b4137369f","b4439890c168d646357928431100daac5cbdee1d345a34e6bf6eca9f3abe22bc","5d72971a459517c44c1379dab9ed248e87a61ba0a1e0f25c9d67e1e640cd9a09","02d734976af36f4273d930bea88b3e62adf6b078cf120c1c63d49aa8d8427c5c",{"version":"516a426e3960379f310107635b8f3a7e8c307c6c665080b128039d9299ec4087","affectsGlobalScope":true},"0359682c54e487c4cab2b53b2b4d35cc8dea4d9914bc6abcdb5701f8b8e745a4","736097ddbb2903bef918bb3b5811ef1c9c5656f2a73bd39b22a91b9cc2525e50","208bb742e0f201470da121bc73847c74b62cff4172f38ae5949ae77d6c9c6b71","062bd2910098fc059ba93e347649b3e126c555f7b144033d21d3f8ef63d3e39b","6fa0008bf91a4cc9c8963bace4bba0bd6865cbfa29c3e3ccc461155660fb113a","2b8264b2fefd7367e0f20e2c04eed5d3038831fe00f5efbc110ff0131aab899b","9d9e658d1d5b805562749ce383ef8c67ccb796394d8734d9c138788d7dab6ee3","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","f7e133b20ee2669b6c0e5d7f0cd510868c57cd64b283e68c7f598e30ce9d76d2","09c4b2e2d3070239d563fc690f0cc5db04a2d9b66a23e61aef8b5274e3e9910c"],"options":{"declaration":true,"declarationDir":"../types","declarationMap":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"importHelpers":true,"importsNotUsedAsValues":2,"module":1,"noEmitHelpers":true,"noImplicitOverride":true,"noUncheckedIndexedAccess":true,"outDir":"./","removeComments":true,"skipLibCheck":true,"sourceMap":true,"strict":true,"target":7},"fileIdsList":[[158,166],[158],[158,166,167,168,169,170],[158,166,168],[131,158,165],[158,175],[158,176],[158,182,184],[133,157,158,165,187,188],[115,158],[118,158],[119,124,158],[120,130,131,138,147,157,158],[120,121,130,138,158],[122,158],[123,124,131,139,158],[124,147,154,158],[125,127,130,138,158],[126,158],[127,128,158],[129,130,158],[130,158],[130,131,132,147,157,158],[130,131,132,147,158],[133,138,147,157,158],[130,131,133,134,138,147,154,157,158],[133,135,147,154,157,158],[115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164],[130,136,158],[137,157,158],[127,130,138,147,158],[139,158],[140,158],[118,141,158],[142,156,158,162],[143,158],[144,158],[130,145,158],[145,146,158,160],[130,147,148,149,158],[147,149,158],[147,148,158],[150,158],[151,158],[130,152,153,158],[152,153,158],[124,138,154,158],[155,158],[138,156,158],[119,133,144,157,158],[124,158],[147,158,159],[158,160],[158,161],[119,124,130,132,141,147,157,158,160,162],[147,158,163],[158,194],[46,88,105,106,158],[50,158],[50,51,158],[46,50,51,73,158],[46,50,51,158],[50,51,62,158],[50,51,60,158],[46,49,50,52,53,54,55,56,57,58,59,60,61,65,67,105,158],[46,49,65,67,73,79,158],[46,65,158],[46,158],[46,62,63,64,66,67,73,78,158],[105,158],[46,66,73,78,79,158],[67,71,73,158],[66,67,158],[65,105,110,158],[46,79,80,158],[46,47,72,73,75,77,78,79,82,158],[46,47,48,71,72,78,79,81,158],[46,47,79,158],[46,48,73,79,158],[46,47,48,72,73,74,75,76,77,79,158],[46,78,79,158],[47,48,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,104,158],[65,66,67,68,69,70,158],[73,75,77,78,79,81,158],[46,78,158],[46,79,158],[46,79,103,158],[46,105,158],[46,83,158],[46,88,105,158],[46,88,89,105,158],[46,88,110,158],[46,86,87,89,90,91,92,93,94,95,96,97,98,99,100,101,102,158],[88,94,105,158],[88,105,158],[46,103,105,107,108,109,158],[133,147,158,165],[158,178,179],[158,178,179,180,181],[158,183],[45,110,158],[45,111,113,158],[45,110,112,158]],"referencedMap":[[168,1],[166,2],[171,3],[167,1],[169,4],[170,1],[172,2],[173,2],[174,5],[175,2],[176,6],[177,7],[185,8],[186,2],[188,2],[189,9],[115,10],[116,10],[118,11],[119,12],[120,13],[121,14],[122,15],[123,16],[124,17],[125,18],[126,19],[127,20],[128,20],[129,21],[130,22],[131,23],[132,24],[117,2],[164,2],[133,25],[134,26],[135,27],[165,28],[136,29],[137,30],[138,31],[139,32],[140,33],[141,34],[142,35],[143,36],[144,37],[145,38],[146,39],[147,40],[149,41],[148,42],[150,43],[151,44],[152,45],[153,46],[154,47],[155,48],[156,49],[157,50],[158,51],[159,52],[160,53],[161,54],[162,55],[163,56],[190,2],[191,2],[192,2],[193,2],[194,2],[195,57],[106,2],[107,58],[46,2],[51,59],[54,60],[56,61],[53,60],[58,62],[59,60],[57,62],[50,2],[52,60],[60,63],[61,64],[55,62],[62,65],[63,66],[49,67],[64,68],[65,69],[70,70],[67,71],[68,72],[69,73],[66,74],[81,75],[83,76],[73,77],[48,78],[74,79],[78,80],[77,81],[105,82],[71,83],[84,84],[85,2],[47,68],[75,85],[72,86],[80,86],[104,87],[79,85],[76,85],[82,88],[86,2],[87,89],[89,90],[90,90],[91,70],[92,91],[93,92],[103,93],[95,94],[96,88],[97,88],[98,90],[99,95],[100,95],[101,90],[102,70],[94,90],[108,2],[88,2],[109,70],[110,96],[187,97],[178,2],[180,98],[182,99],[181,98],[179,2],[184,100],[183,2],[45,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[4,2],[23,2],[20,2],[21,2],[22,2],[24,2],[25,2],[26,2],[5,2],[27,2],[28,2],[29,2],[30,2],[6,2],[31,2],[32,2],[33,2],[34,2],[7,2],[39,2],[35,2],[36,2],[37,2],[38,2],[8,2],[43,2],[40,2],[41,2],[42,2],[1,2],[9,2],[44,2],[111,101],[114,102],[113,103],[112,2]],"exportedModulesMap":[[168,1],[166,2],[171,3],[167,1],[169,4],[170,1],[172,2],[173,2],[174,5],[175,2],[176,6],[177,7],[185,8],[186,2],[188,2],[189,9],[115,10],[116,10],[118,11],[119,12],[120,13],[121,14],[122,15],[123,16],[124,17],[125,18],[126,19],[127,20],[128,20],[129,21],[130,22],[131,23],[132,24],[117,2],[164,2],[133,25],[134,26],[135,27],[165,28],[136,29],[137,30],[138,31],[139,32],[140,33],[141,34],[142,35],[143,36],[144,37],[145,38],[146,39],[147,40],[149,41],[148,42],[150,43],[151,44],[152,45],[153,46],[154,47],[155,48],[156,49],[157,50],[158,51],[159,52],[160,53],[161,54],[162,55],[163,56],[190,2],[191,2],[192,2],[193,2],[194,2],[195,57],[106,2],[107,58],[46,2],[51,59],[54,60],[56,61],[53,60],[58,62],[59,60],[57,62],[50,2],[52,60],[60,63],[61,64],[55,62],[62,65],[63,66],[49,67],[64,68],[65,69],[70,70],[67,71],[68,72],[69,73],[66,74],[81,75],[83,76],[73,77],[48,78],[74,79],[78,80],[77,81],[105,82],[71,83],[84,84],[85,2],[47,68],[75,85],[72,86],[80,86],[104,87],[79,85],[76,85],[82,88],[86,2],[87,89],[89,90],[90,90],[91,70],[92,91],[93,92],[103,93],[95,94],[96,88],[97,88],[98,90],[99,95],[100,95],[101,90],[102,70],[94,90],[108,2],[88,2],[109,70],[110,96],[187,97],[178,2],[180,98],[182,99],[181,98],[179,2],[184,100],[183,2],[45,2],[11,2],[10,2],[2,2],[12,2],[13,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[3,2],[4,2],[23,2],[20,2],[21,2],[22,2],[24,2],[25,2],[26,2],[5,2],[27,2],[28,2],[29,2],[30,2],[6,2],[31,2],[32,2],[33,2],[34,2],[7,2],[39,2],[35,2],[36,2],[37,2],[38,2],[8,2],[43,2],[40,2],[41,2],[42,2],[1,2],[9,2],[44,2],[111,101],[114,102],[113,103],[112,2]],"semanticDiagnosticsPerFile":[168,166,171,167,169,170,172,173,174,175,176,177,185,186,188,189,115,116,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,117,164,133,134,135,165,136,137,138,139,140,141,142,143,144,145,146,147,149,148,150,151,152,153,154,155,156,157,158,159,160,161,162,163,190,191,192,193,194,195,106,107,46,51,54,56,53,58,59,57,50,52,60,61,55,62,63,49,64,65,70,67,68,69,66,81,83,73,48,74,78,77,105,71,84,85,47,75,72,80,104,79,76,82,86,87,89,90,91,92,93,103,95,96,97,98,99,100,101,102,94,108,88,109,110,187,178,180,182,181,179,184,183,45,11,10,2,12,13,14,15,16,17,18,19,3,4,23,20,21,22,24,25,26,5,27,28,29,30,6,31,32,33,34,7,39,35,36,37,38,8,43,40,41,42,1,9,44,111,114,113,112]},"version":"4.5.4"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/package",
3
+ "name": "@chatsift/discord-utils",
4
+ "description": "Niche utilities for working with Discord's API",
5
+ "main": "./dist/index.js",
6
+ "types": "./types/index.d.ts",
7
+ "version": "0.1.0",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/ChatSift/packages.git"
11
+ },
12
+ "author": "didinele",
13
+ "bugs": {
14
+ "url": "https://github.com/ChatSift/packages/issues"
15
+ },
16
+ "homepage": "https://github.com/ChatSift/packages#readme",
17
+ "devDependencies": {
18
+ "@types/node": "^16.11.19",
19
+ "typescript": "^4.5.4"
20
+ },
21
+ "dependencies": {
22
+ "@chatsift/utils": "^0.1.0",
23
+ "discord-api-types": "^0.26.1",
24
+ "tslib": "^2.3.1"
25
+ },
26
+ "scripts": {
27
+ "lint": "eslint src --ext .ts",
28
+ "build": "tsc"
29
+ },
30
+ "readme": "# `@chatsift/discord-utils`\n\n[![GitHub](https://img.shields.io/badge/License-GNU%20AGPLv3-yellow.svg)](https://github.com/ChatSift/packages/blob/main/LICENSE)\n[![npm](https://img.shields.io/npm/v/@chatsift/discord-utils?color=crimson&logo=npm)](https://www.npmjs.com/package/@chatsift/discord-utils)\n[![TypeScript](https://github.com/ChatSift/packages/actions/workflows/quality.yml/badge.svg)](https://github.com/ChatSift/packages/actions/workflows/quality.yml)\n\nNiche utilities for working with Discord's API\n\n## Installation\n\n- `npm install @chatsift/discord-utils`\n- `pnpm install @chatsift/discord-utils`\n- `yarn add @chatsift/discord-utils`\n\n## Contributing\n\nPlease see the main [README.md](https://github.com/ChatSift/packages) for info on how to contribute to this package or the other `@chatsift` packages.\n\n## LICENSE\n\nThis project is licensed under the GNU AGPLv3 license.\n\nIt should, however, be noted that some packages are forks of other open source projects, and are therefore, sub-licensed.\n"
31
+ }
@@ -0,0 +1,58 @@
1
+ import type { APIEmbed, APIEmbedField } from 'discord-api-types/v9';
2
+ import { addFields, ellipsis, MESSAGE_LIMITS, truncateEmbed } from '../embed';
3
+
4
+ describe('addFields', () => {
5
+ test('no existing fields', () => {
6
+ const embed: APIEmbed = {};
7
+
8
+ const field: APIEmbedField = { name: 'foo', value: 'bar' };
9
+ expect(addFields(embed, field)).toStrictEqual({ ...embed, fields: [field] });
10
+ });
11
+
12
+ test('existing fields', () => {
13
+ const field: APIEmbedField = { name: 'foo', value: 'bar' };
14
+ const embed: APIEmbed = { fields: [field] };
15
+
16
+ expect(addFields(embed, field)).toStrictEqual({ ...embed, fields: [field, field] });
17
+ });
18
+ });
19
+
20
+ describe('ellipsis', () => {
21
+ test('no ellipsis', () => {
22
+ expect(ellipsis('foo', 5)).toBe('foo');
23
+ });
24
+
25
+ test('ellipsis', () => {
26
+ expect(ellipsis('foobar', 4)).toBe('f...');
27
+ });
28
+
29
+ test('too long for ellipsis', () => {
30
+ expect(ellipsis('foo', 2)).toBe('fo');
31
+ });
32
+ });
33
+
34
+ describe('truncateEmbed', () => {
35
+ test('basic embed properties', () => {
36
+ const embed: APIEmbed = {
37
+ title: 'foo'.repeat(256),
38
+ description: 'bar'.repeat(4096),
39
+ author: { name: 'baz'.repeat(256) },
40
+ footer: { text: 'qux'.repeat(2048) },
41
+ };
42
+
43
+ const truncated = truncateEmbed(embed);
44
+
45
+ expect(truncated.title).toBe(ellipsis(embed.title, MESSAGE_LIMITS.EMBEDS.TITLE));
46
+ expect(truncated.description).toBe(ellipsis(embed.description, MESSAGE_LIMITS.EMBEDS.DESCRIPTION));
47
+ expect(truncated.author.name).toBe(ellipsis(embed.author.name, MESSAGE_LIMITS.EMBEDS.AUTHOR));
48
+ expect(truncated.footer.text).toBe(ellipsis(embed.footer.text, MESSAGE_LIMITS.EMBEDS.FOOTER));
49
+ });
50
+
51
+ test('fields', () => {
52
+ const embed: APIEmbed = {
53
+ fields: Array(30).fill({ name: 'foo', value: 'bar' }),
54
+ };
55
+
56
+ expect(truncateEmbed(embed).fields).toHaveLength(MESSAGE_LIMITS.EMBEDS.FIELD_COUNT);
57
+ });
58
+ });
@@ -0,0 +1,33 @@
1
+ import { sortChannels } from '../sortChannels';
2
+ import { ChannelType, APIChannel } from 'discord-api-types/v9';
3
+
4
+ test('sorting a list of channels', () => {
5
+ // Higher position than the category, but should come out on top
6
+ const first = {
7
+ id: '1',
8
+ position: 1,
9
+ type: ChannelType.GuildText,
10
+ } as unknown as APIChannel;
11
+
12
+ const second = {
13
+ id: '0',
14
+ position: 0,
15
+ type: ChannelType.GuildCategory,
16
+ } as unknown as APIChannel;
17
+
18
+ const third = {
19
+ id: '2',
20
+ position: 0,
21
+ type: ChannelType.GuildText,
22
+ parent_id: '0',
23
+ } as unknown as APIChannel;
24
+
25
+ const fourth = {
26
+ id: '3',
27
+ position: 1,
28
+ type: ChannelType.GuildText,
29
+ parent_id: '0',
30
+ } as unknown as APIChannel;
31
+
32
+ expect(sortChannels([first, second, third, fourth])).toStrictEqual([first, second, third, fourth]);
33
+ });
package/src/embed.ts ADDED
@@ -0,0 +1,113 @@
1
+ import type { APIEmbed, APIEmbedField } from 'discord-api-types/v9';
2
+
3
+ /**
4
+ * Limits commonly encountered with Discord's API
5
+ */
6
+ export const MESSAGE_LIMITS = {
7
+ /**
8
+ * How long a message can be in characters
9
+ */
10
+ CONTENT: 4000,
11
+ /**
12
+ * How many embeds can be in a message
13
+ */
14
+ EMBED_COUNT: 10,
15
+ /**
16
+ * Embed specific limits
17
+ */
18
+ EMBEDS: {
19
+ /**
20
+ * How long an embed title can be in characters
21
+ */
22
+ TITLE: 256,
23
+ /**
24
+ * How long an embed description can be in characters
25
+ */
26
+ DESCRIPTION: 4096,
27
+ /**
28
+ * How long an embed footer can be in characters
29
+ */
30
+ FOOTER: 2048,
31
+ /**
32
+ * How long an embed author can be in characters
33
+ */
34
+ AUTHOR: 256,
35
+ /**
36
+ * How many fields an embed can have
37
+ */
38
+ FIELD_COUNT: 25,
39
+ /**
40
+ * Field specific limits
41
+ */
42
+ FIELDS: {
43
+ /**
44
+ * How long a field name can be in characters
45
+ */
46
+ NAME: 256,
47
+ /**
48
+ * How long a field value can be in characters
49
+ */
50
+ VALUE: 1024,
51
+ },
52
+ },
53
+ } as const;
54
+
55
+ /**
56
+ * Adds the given fields to an embed - mutating it
57
+ * @param embed The embed to add fields to
58
+ * @param fields The fields to add
59
+ */
60
+ export function addFields(embed: APIEmbed, ...fields: APIEmbedField[]): APIEmbed {
61
+ (embed.fields ??= []).push(...fields);
62
+ return embed;
63
+ }
64
+
65
+ /**
66
+ * Cuts off text after the given length - appending "..." at the end
67
+ * @param text The text to cut off
68
+ * @param total The maximum length of the text
69
+ */
70
+ export function ellipsis(text: string, total: number): string {
71
+ if (text.length <= total) {
72
+ return text;
73
+ }
74
+
75
+ const keep = total - 3;
76
+ if (keep < 1) {
77
+ return text.slice(0, total);
78
+ }
79
+
80
+ return `${text.slice(0, keep)}...`;
81
+ }
82
+
83
+ /**
84
+ * Returns a fully truncated embed - safe to use with Discord's API - does not mutate the given embed
85
+ * @param embed The embed to truncate
86
+ */
87
+ export function truncateEmbed(embed: APIEmbed): APIEmbed {
88
+ return {
89
+ ...embed,
90
+ description: embed.description ? ellipsis(embed.description, MESSAGE_LIMITS.EMBEDS.DESCRIPTION) : undefined,
91
+ title: embed.title ? ellipsis(embed.title, MESSAGE_LIMITS.EMBEDS.TITLE) : undefined,
92
+ author: embed.author
93
+ ? {
94
+ ...embed.author,
95
+ name: ellipsis(embed.author.name, MESSAGE_LIMITS.EMBEDS.AUTHOR),
96
+ }
97
+ : undefined,
98
+ footer: embed.footer
99
+ ? {
100
+ ...embed.footer,
101
+ text: ellipsis(embed.footer.text, MESSAGE_LIMITS.EMBEDS.FOOTER),
102
+ }
103
+ : undefined,
104
+ fields: embed.fields
105
+ ? embed.fields
106
+ .map((field) => ({
107
+ name: ellipsis(field.name, MESSAGE_LIMITS.EMBEDS.FIELDS.NAME),
108
+ value: ellipsis(field.value, MESSAGE_LIMITS.EMBEDS.FIELDS.VALUE),
109
+ }))
110
+ .slice(0, MESSAGE_LIMITS.EMBEDS.FIELD_COUNT)
111
+ : [],
112
+ };
113
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './embed';
2
+ export * from './sortChannels';
@@ -0,0 +1,36 @@
1
+ import { groupBy } from '@chatsift/utils';
2
+ import { APIChannel, ChannelType } from 'discord-api-types/v9';
3
+
4
+ /**
5
+ * Sorts an array of text and category channels - **does not support other channel types**
6
+ */
7
+ export function sortChannels(unsorted: APIChannel[]): APIChannel[] {
8
+ // Group the channels by their category - or "top" if they aren't in one
9
+ const grouped = groupBy(unsorted, (c) => c.parent_id ?? 'top');
10
+
11
+ // Sort the top level channels - text channels are above category channels, otherwise use their position
12
+ const sortedTopLevel = grouped.top
13
+ ?.filter((channel) => !channel.parent_id)
14
+ .sort((a, b) => {
15
+ if (a.type === ChannelType.GuildText && b.type === ChannelType.GuildCategory) {
16
+ return -1;
17
+ }
18
+
19
+ if (a.type === ChannelType.GuildCategory && b.type === ChannelType.GuildText) {
20
+ return 1;
21
+ }
22
+
23
+ return a.position! - b.position!;
24
+ });
25
+
26
+ const channels = [];
27
+ for (const top of sortedTopLevel ?? []) {
28
+ channels.push(top);
29
+
30
+ if (top.type === ChannelType.GuildCategory) {
31
+ channels.push(...(grouped[top.id] ?? []).sort((a, b) => a.position! - b.position!));
32
+ }
33
+ }
34
+
35
+ return channels.length ? channels : unsorted.sort((a, b) => a.position! - b.position!);
36
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.eslint.json"
3
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "declarationDir": "./types",
6
+ "declaration": true,
7
+ "declarationMap": true
8
+ },
9
+ "include": ["./src/**/*.ts"]
10
+ }
@@ -0,0 +1,20 @@
1
+ import type { APIEmbed, APIEmbedField } from 'discord-api-types/v9';
2
+ export declare const MESSAGE_LIMITS: {
3
+ readonly CONTENT: 4000;
4
+ readonly EMBED_COUNT: 10;
5
+ readonly EMBEDS: {
6
+ readonly TITLE: 256;
7
+ readonly DESCRIPTION: 4096;
8
+ readonly FOOTER: 2048;
9
+ readonly AUTHOR: 256;
10
+ readonly FIELD_COUNT: 25;
11
+ readonly FIELDS: {
12
+ readonly NAME: 256;
13
+ readonly VALUE: 1024;
14
+ };
15
+ };
16
+ };
17
+ export declare function addFields(embed: APIEmbed, ...fields: APIEmbedField[]): APIEmbed;
18
+ export declare function ellipsis(text: string, total: number): string;
19
+ export declare function truncateEmbed(embed: APIEmbed): APIEmbed;
20
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKpE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;CA+CjB,CAAC;AAOX,wBAAgB,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,CAG/E;AAOD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAW5D;AAMD,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CA0BvD"}
@@ -0,0 +1,3 @@
1
+ export * from './embed';
2
+ export * from './sortChannels';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { APIChannel } from 'discord-api-types/v9';
2
+ export declare function sortChannels(unsorted: APIChannel[]): APIChannel[];
3
+ //# sourceMappingURL=sortChannels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortChannels.d.ts","sourceRoot":"","sources":["../src/sortChannels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAe,MAAM,sBAAsB,CAAC;AAK/D,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CA6BjE"}