@skyhelperbot/utils 2.0.2 → 2.1.1

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/dist/typings.d.ts CHANGED
@@ -1,5 +1,29 @@
1
- import { Client, Collection } from "discord.js";
2
- import moment from "moment-timezone";
1
+ /// <reference types="mongoose/types/aggregate.js" />
2
+ /// <reference types="mongoose/types/callback.js" />
3
+ /// <reference types="mongoose/types/collection.js" />
4
+ /// <reference types="mongoose/types/connection.js" />
5
+ /// <reference types="mongoose/types/cursor.js" />
6
+ /// <reference types="mongoose/types/document.js" />
7
+ /// <reference types="mongoose/types/error.js" />
8
+ /// <reference types="mongoose/types/expressions.js" />
9
+ /// <reference types="mongoose/types/helpers.js" />
10
+ /// <reference types="mongoose/types/middlewares.js" />
11
+ /// <reference types="mongoose/types/indexes.js" />
12
+ /// <reference types="mongoose/types/models.js" />
13
+ /// <reference types="mongoose/types/mongooseoptions.js" />
14
+ /// <reference types="mongoose/types/pipelinestage.js" />
15
+ /// <reference types="mongoose/types/populate.js" />
16
+ /// <reference types="mongoose/types/query.js" />
17
+ /// <reference types="mongoose/types/schemaoptions.js" />
18
+ /// <reference types="mongoose/types/schematypes.js" />
19
+ /// <reference types="mongoose/types/session.js" />
20
+ /// <reference types="mongoose/types/types.js" />
21
+ /// <reference types="mongoose/types/utility.js" />
22
+ /// <reference types="mongoose/types/validation.js" />
23
+ /// <reference types="mongoose/types/virtuals.js" />
24
+ /// <reference types="mongoose/types/inferschematype.js" />
25
+ /// <reference types="mongoose/types/inferrawdoctype.js" />
26
+ import type { DateTime } from "luxon";
3
27
  import { Document } from "mongoose";
4
28
  /** Data of users provided for making a game leaderboard card */
5
29
  export interface userData {
@@ -34,13 +58,10 @@ export interface Background {
34
58
  export interface SkyEvent {
35
59
  eventActive: Boolean;
36
60
  eventName: string;
37
- eventStarts: moment.Moment;
38
- eventEnds: moment.Moment;
61
+ eventStarts: DateTime;
62
+ eventEnds: DateTime;
39
63
  eventDuration: string;
40
64
  }
41
- export interface SkyHelper extends Client {
42
- skyEvents: Collection<string, SkyEvent>;
43
- }
44
65
  export interface TSData extends Document {
45
66
  name: string;
46
67
  visitDate: string;
@@ -56,7 +77,7 @@ export interface ShardsCountdown {
56
77
  index: number;
57
78
  active?: boolean;
58
79
  ended?: boolean;
59
- start: moment.Moment;
60
- end: moment.Moment;
80
+ start: DateTime;
81
+ end: DateTime;
61
82
  duration: string;
62
83
  }
package/dist/typings.js CHANGED
@@ -1,3 +1 @@
1
- import { Client, Collection } from "discord.js";
2
- import moment from "moment-timezone";
3
1
  import { Document } from "mongoose";
@@ -1,5 +1,5 @@
1
- export { buildTimesHTML, type Field } from "./buildTimesHTML.js";
2
- export { postToHaste } from "./postToBin.js";
3
- export { parsePerms, type Permission } from "./parsePerms.js";
4
- export { recursiveReadDir } from "./recursiveReadDir.js";
5
- export { parseDateFormat } from "./parseDateFormat.js";
1
+ export * from "./postToBin.js";
2
+ export * from "./parsePerms.js";
3
+ export * from "./recursiveReadDir.js";
4
+ export * from "./parseDateFormat.js";
5
+ export * from "./resolveColors.js";
@@ -1,5 +1,5 @@
1
- export { buildTimesHTML } from "./buildTimesHTML.js";
2
- export { postToHaste } from "./postToBin.js";
3
- export { parsePerms } from "./parsePerms.js";
4
- export { recursiveReadDir } from "./recursiveReadDir.js";
5
- export { parseDateFormat } from "./parseDateFormat.js";
1
+ export * from "./postToBin.js";
2
+ export * from "./parsePerms.js";
3
+ export * from "./recursiveReadDir.js";
4
+ export * from "./parseDateFormat.js";
5
+ export * from "./resolveColors.js";
@@ -0,0 +1,79 @@
1
+ /** Original code credit to discord.js */
2
+ /**
3
+ * Can be a number, hex string, an RGB array like:
4
+ * ```js
5
+ * [255, 0, 255] // purple
6
+ * ```
7
+ * or one of the following strings:
8
+ * - `Default`
9
+ * - `White`
10
+ * - `Aqua`
11
+ * - `Green`
12
+ * - `Blue`
13
+ * - `Yellow`
14
+ * - `Purple`
15
+ * - `LuminousVividPink`
16
+ * - `Fuchsia`
17
+ * - `Gold`
18
+ * - `Orange`
19
+ * - `Red`
20
+ * - `Grey`
21
+ * - `Navy`
22
+ * - `DarkAqua`
23
+ * - `DarkGreen`
24
+ * - `DarkBlue`
25
+ * - `DarkPurple`
26
+ * - `DarkVividPink`
27
+ * - `DarkGold`
28
+ * - `DarkOrange`
29
+ * - `DarkRed`
30
+ * - `DarkGrey`
31
+ * - `DarkerGrey`
32
+ * - `LightGrey`
33
+ * - `DarkNavy`
34
+ * - `Blurple`
35
+ * - `Greyple`
36
+ * - `DarkButNotBlack`
37
+ * - `NotQuiteBlack`
38
+ * - `Random`
39
+ */
40
+ export type ColorResolvable = keyof typeof Colors | "Random" | "Default" | `#${string}` | number | number[];
41
+ /**
42
+ * Resolves a ColorResolvable into a color number.
43
+ * @param color Color to resolve
44
+ * @returns A color
45
+ */
46
+ export declare function resolveColor(color: ColorResolvable): number;
47
+ declare const Colors: {
48
+ Default: number;
49
+ White: number;
50
+ Aqua: number;
51
+ Green: number;
52
+ Blue: number;
53
+ Yellow: number;
54
+ Purple: number;
55
+ LuminousVividPink: number;
56
+ Fuchsia: number;
57
+ Gold: number;
58
+ Orange: number;
59
+ Red: number;
60
+ Grey: number;
61
+ Navy: number;
62
+ DarkAqua: number;
63
+ DarkGreen: number;
64
+ DarkBlue: number;
65
+ DarkPurple: number;
66
+ DarkVividPink: number;
67
+ DarkGold: number;
68
+ DarkOrange: number;
69
+ DarkRed: number;
70
+ DarkGrey: number;
71
+ DarkerGrey: number;
72
+ LightGrey: number;
73
+ DarkNavy: number;
74
+ Blurple: number;
75
+ Greyple: number;
76
+ DarkButNotBlack: number;
77
+ NotQuiteBlack: number;
78
+ };
79
+ export {};
@@ -0,0 +1,63 @@
1
+ /** Original code credit to discord.js */
2
+ /**
3
+ * Resolves a ColorResolvable into a color number.
4
+ * @param color Color to resolve
5
+ * @returns A color
6
+ */
7
+ export function resolveColor(color) {
8
+ let resolvedColor;
9
+ if (typeof color === "string") {
10
+ if (color === "Random")
11
+ return Math.floor(Math.random() * (0xffffff + 1));
12
+ if (color === "Default")
13
+ return 0;
14
+ if (/^#?[\da-f]{6}$/i.test(color))
15
+ return parseInt(color.replace("#", ""), 16);
16
+ resolvedColor = Colors[color];
17
+ }
18
+ else if (Array.isArray(color)) {
19
+ resolvedColor = (color[0] << 16) + (color[1] << 8) + color[2];
20
+ }
21
+ else {
22
+ resolvedColor = color;
23
+ }
24
+ if (!Number.isInteger(resolvedColor)) {
25
+ throw new Error("Not a number");
26
+ }
27
+ if (resolvedColor < 0 || resolvedColor > 0xffffff) {
28
+ throw new Error("Not in color range");
29
+ }
30
+ return resolvedColor;
31
+ }
32
+ const Colors = {
33
+ Default: 0x000000,
34
+ White: 0xffffff,
35
+ Aqua: 0x1abc9c,
36
+ Green: 0x57f287,
37
+ Blue: 0x3498db,
38
+ Yellow: 0xfee75c,
39
+ Purple: 0x9b59b6,
40
+ LuminousVividPink: 0xe91e63,
41
+ Fuchsia: 0xeb459e,
42
+ Gold: 0xf1c40f,
43
+ Orange: 0xe67e22,
44
+ Red: 0xed4245,
45
+ Grey: 0x95a5a6,
46
+ Navy: 0x34495e,
47
+ DarkAqua: 0x11806a,
48
+ DarkGreen: 0x1f8b4c,
49
+ DarkBlue: 0x206694,
50
+ DarkPurple: 0x71368a,
51
+ DarkVividPink: 0xad1457,
52
+ DarkGold: 0xc27c0e,
53
+ DarkOrange: 0xa84300,
54
+ DarkRed: 0x992d22,
55
+ DarkGrey: 0x979c9f,
56
+ DarkerGrey: 0x7f8c8d,
57
+ LightGrey: 0xbcc0c0,
58
+ DarkNavy: 0x2c3e50,
59
+ Blurple: 0x5865f2,
60
+ Greyple: 0x99aab5,
61
+ DarkButNotBlack: 0x2c2f33,
62
+ NotQuiteBlack: 0x23272a,
63
+ };
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@skyhelperbot/utils",
3
- "version": "2.0.2",
3
+ "version": "2.1.1",
4
4
  "description": "Utilities for SkyHelper bot",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/imnaiyar/skyhelper/packages/utils"
10
+ "url": "https://github.com/imnaiyar/skyhelper.git",
11
+ "directory": "packages/utils"
11
12
  },
12
13
  "keywords": [
13
14
  "SkyHelperUtils",
@@ -24,21 +25,24 @@
24
25
  "bugs": {
25
26
  "url": "https://github.com/imnaiyar/skyhelper/issues"
26
27
  },
27
- "homepage": "https://github.com/imnaiyar/skyhelper/packages/utils#readme",
28
+ "homepage": "https://github.com/imnaiyar/skyhelper/tree/main/packages/utils",
28
29
  "dependencies": {
29
30
  "@napi-rs/canvas": "^0.1.51",
30
- "discord.js": "14.16.2",
31
- "moment-duration-format": "^2.3.2",
32
- "moment-timezone": "^0.5.45",
33
- "typescript": "^5.4.3",
34
- "undici": "^6.13.0"
31
+ "discord-api-types": "^0.37.93",
32
+ "undici": "^7.2.3"
35
33
  },
36
34
  "devDependencies": {
37
- "@types/moment-duration-format": "^2.2.6",
38
- "mongoose": "^8.3.2"
35
+ "@types/luxon": "^3.4.2",
36
+ "luxon": "^3.5.0",
37
+ "mongoose": "^8.3.2",
38
+ "typescript": "^5.4.3"
39
+ },
40
+ "peerDependencies": {
41
+ "luxon": "^3.5.0"
39
42
  },
40
43
  "scripts": {
41
44
  "build": "tsc && echo 'Files compiled'",
42
- "build:docs": "typedoc"
45
+ "build:docs": "typedoc",
46
+ "lint": "eslint --fix src"
43
47
  }
44
48
  }
@@ -1,30 +0,0 @@
1
- import type { SpecialEventData } from "../typings.js";
2
- /**
3
- * @class
4
- * @classdesc A class to update Events details in the client constructor
5
- * @method update Updates the event details
6
- */
7
- export declare class UpdateEvent {
8
- readonly data: SpecialEventData;
9
- constructor(data: SpecialEventData);
10
- /**
11
- * @param name Name of the event
12
- */
13
- setName(name: string): this;
14
- /**
15
- * @param date Start date of the Event. Format DD-MM-YYYY
16
- * @example
17
- * new UpdateEvent().setDate('22-09-2023')
18
- */
19
- setStart(date: string): this;
20
- /**
21
- * @param date End date of the Event. Format DD-MM-YYYY
22
- * @example
23
- * new UpdateEvent().setDate('22-09-2023')
24
- */
25
- setEnd(date: string): this;
26
- /**
27
- * @returns The updated event
28
- */
29
- update(): Promise<SpecialEventData>;
30
- }
@@ -1,52 +0,0 @@
1
- import moment from "moment-timezone";
2
- /**
3
- * @class
4
- * @classdesc A class to update Events details in the client constructor
5
- * @method update Updates the event details
6
- */
7
- export class UpdateEvent {
8
- data;
9
- constructor(data) {
10
- this.data = data;
11
- }
12
- /**
13
- * @param name Name of the event
14
- */
15
- setName(name) {
16
- if (!name || typeof name !== "string") {
17
- throw new TypeError("Name must be a non-empty string.");
18
- }
19
- this.data.name = name;
20
- return this;
21
- }
22
- /**
23
- * @param date Start date of the Event. Format DD-MM-YYYY
24
- * @example
25
- * new UpdateEvent().setDate('22-09-2023')
26
- */
27
- setStart(date) {
28
- if (!date || typeof date !== "string") {
29
- throw new TypeError("Date must be a non-empty string.");
30
- }
31
- this.data.startDate = date;
32
- return this;
33
- }
34
- /**
35
- * @param date End date of the Event. Format DD-MM-YYYY
36
- * @example
37
- * new UpdateEvent().setDate('22-09-2023')
38
- */
39
- setEnd(date) {
40
- if (!date || typeof date !== "string") {
41
- throw new TypeError("Date must be a non-empty string.");
42
- }
43
- this.data.endDate = date;
44
- return this;
45
- }
46
- /**
47
- * @returns The updated event
48
- */
49
- async update() {
50
- return await this.data.save();
51
- }
52
- }
@@ -1,35 +0,0 @@
1
- import type { TSData } from "../typings.js";
2
- /**
3
- * @class
4
- * @classdesc A class to update traveling spirit details in the client constructor
5
- * @method update updates the ts details
6
- * @returns {Object}
7
- */
8
- export declare class UpdateTS {
9
- readonly data: TSData;
10
- constructor(data: TSData);
11
- /**
12
- * Sets the name of the TS
13
- * @param name Name of the returning TS
14
- */
15
- setName(name: string): this;
16
- /**
17
- * Sets the visit date of the ts
18
- * @param date Returnig date. Format: DD-MM-YYYY
19
- */
20
- setVisit(date: string): this;
21
- /**
22
- * Sets the value of the t spirit
23
- * @param value The value of the spirit in the spiritsData
24
- */
25
- setValue(value: string): this;
26
- /**
27
- * Sets the index of the returning ts
28
- * @param index The returning index of the TS
29
- */
30
- setIndex(index: number): this;
31
- /**
32
- * returns the updated ts details
33
- */
34
- update(): Promise<TSData>;
35
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * @class
3
- * @classdesc A class to update traveling spirit details in the client constructor
4
- * @method update updates the ts details
5
- * @returns {Object}
6
- */
7
- export class UpdateTS {
8
- data;
9
- constructor(data) {
10
- this.data = data;
11
- }
12
- /**
13
- * Sets the name of the TS
14
- * @param name Name of the returning TS
15
- */
16
- setName(name) {
17
- if (!name || typeof name !== "string") {
18
- throw new TypeError("Name must be a non-empty string.");
19
- }
20
- this.data.name = name;
21
- return this;
22
- }
23
- /**
24
- * Sets the visit date of the ts
25
- * @param date Returnig date. Format: DD-MM-YYYY
26
- */
27
- setVisit(date) {
28
- if (!date || typeof date !== "string") {
29
- throw new TypeError("Date must be a non-empty string.");
30
- }
31
- this.data.visitDate = date;
32
- return this;
33
- }
34
- /**
35
- * Sets the value of the t spirit
36
- * @param value The value of the spirit in the spiritsData
37
- */
38
- setValue(value) {
39
- if (!value || typeof value !== "string") {
40
- throw new TypeError("Value must be a non-empty string.");
41
- }
42
- this.data.value = value;
43
- return this;
44
- }
45
- /**
46
- * Sets the index of the returning ts
47
- * @param index The returning index of the TS
48
- */
49
- setIndex(index) {
50
- if (!index || typeof index !== "number") {
51
- throw new TypeError("Index must be a number.");
52
- }
53
- this.data.index = index;
54
- return this;
55
- }
56
- /**
57
- * returns the updated ts details
58
- */
59
- async update() {
60
- return await this.data.save();
61
- }
62
- }
@@ -1,14 +0,0 @@
1
- import { type ChatInputCommandInteraction } from "discord.js";
2
- export interface Field {
3
- name: string;
4
- example: string;
5
- value: string;
6
- }
7
- /**
8
- * Dynamically builds a timestamp sweb page html with the given data
9
- * @param interaction The interaction that intiated this
10
- * @param fieldsData The data about times
11
- * @param offset Offset of the timezone
12
- * @param providedTime
13
- */
14
- export declare const buildTimesHTML: (interaction: ChatInputCommandInteraction, fieldsData: Field[], offset: string, providedTime: string) => string;