@fallencodes/seyfert-utils 1.2.6 → 1.2.7
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/build/utilities.d.ts +4 -0
- package/build/utilities.d.ts.map +1 -1
- package/build/utilities.js +20 -0
- package/package.json +1 -1
package/build/utilities.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { User, GuildMember, InteractionGuildMember } from 'seyfert';
|
|
2
|
+
import { APIRoleColors } from 'seyfert/lib/types/index.js';
|
|
3
|
+
import { ObjectToLower } from 'seyfert/lib/common/index.js';
|
|
2
4
|
export declare function s(content: string): string;
|
|
3
5
|
export declare function randomId(length: number): string;
|
|
4
6
|
export declare function wait(time: number): Promise<unknown>;
|
|
@@ -9,5 +11,7 @@ export declare function name(user: User | GuildMember | InteractionGuildMember,
|
|
|
9
11
|
export declare function reviver(_key: string, value: any): any;
|
|
10
12
|
export declare function replacer(_key: string, value: any): any;
|
|
11
13
|
export declare function numberToHex(color: number): string;
|
|
14
|
+
export declare function apiRoleColorsToArray(apiColors: APIRoleColors | ObjectToLower<APIRoleColors>): number[];
|
|
15
|
+
export declare function getValueFromPath<T extends Record<string, any>>(object: T, path: string): unknown | undefined;
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=utilities.d.ts.map
|
package/build/utilities.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAA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
;
|
|
72
|
+
/* Converts the API role colors object to an array of colors. */
|
|
73
|
+
export function apiRoleColorsToArray(apiColors) {
|
|
74
|
+
const primaryColor = 'primaryColor' in apiColors ? apiColors.primaryColor : apiColors.primary_color;
|
|
75
|
+
const secondaryColor = 'secondaryColor' in apiColors ? apiColors.secondaryColor : apiColors.secondary_color;
|
|
76
|
+
const tertiaryColor = 'tertiaryColor' in apiColors ? apiColors.tertiaryColor : apiColors.tertiary_color;
|
|
77
|
+
const colors = [];
|
|
78
|
+
if (primaryColor !== 0)
|
|
79
|
+
colors.push(primaryColor);
|
|
80
|
+
if (secondaryColor)
|
|
81
|
+
colors.push(secondaryColor);
|
|
82
|
+
if (tertiaryColor)
|
|
83
|
+
colors.push(tertiaryColor);
|
|
84
|
+
return colors;
|
|
85
|
+
}
|
|
86
|
+
;
|
|
87
|
+
/* Gets a value from an object with the specified path. */
|
|
88
|
+
export function getValueFromPath(object, path) {
|
|
89
|
+
return path.split('.').reduce((acc, key) => ((acc && (key in acc)) ? acc[key] : undefined), object);
|
|
90
|
+
}
|
|
91
|
+
;
|
package/package.json
CHANGED