@skyhelperbot/utils 2.1.0 → 2.2.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.
Files changed (54) hide show
  1. package/dist/index.js +3 -4
  2. package/dist/{classes → types/classes}/SkytimesUtils.d.ts +4 -5
  3. package/dist/types/classes/index.d.ts +3 -0
  4. package/dist/types/classes/shardsUtil.d.ts +77 -0
  5. package/dist/{classes → types/classes}/utils.d.ts +3 -0
  6. package/dist/types/constants/eventDatas.d.ts +31 -0
  7. package/dist/{constants → types/constants}/index.d.ts +1 -0
  8. package/dist/{constants → types/constants}/shardsInfo.d.ts +12 -16
  9. package/dist/{constants → types/constants}/shardsTimeline.d.ts +3 -2
  10. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  11. package/dist/types/typings.d.ts +29 -0
  12. package/dist/types/utils/PermissionUtils.d.ts +84 -0
  13. package/dist/types/utils/getNextTs.d.ts +10 -0
  14. package/dist/types/utils/index.d.ts +16 -0
  15. package/dist/{utils → types/utils}/parseDateFormat.d.ts +1 -0
  16. package/dist/{utils → types/utils}/parsePerms.d.ts +2 -0
  17. package/dist/{utils → types/utils}/postToBin.d.ts +1 -0
  18. package/dist/{utils → types/utils}/recursiveReadDir.d.ts +1 -0
  19. package/dist/{utils → types/utils}/resolveColors.d.ts +1 -0
  20. package/dist/types/utils/v2-builders.d.ts +14 -0
  21. package/package.json +17 -11
  22. package/dist/classes/LeaderBoardCard.d.ts +0 -59
  23. package/dist/classes/LeaderBoardCard.js +0 -249
  24. package/dist/classes/SkytimesUtils.js +0 -116
  25. package/dist/classes/WinnerCard.d.ts +0 -13
  26. package/dist/classes/WinnerCard.js +0 -117
  27. package/dist/classes/index.d.ts +0 -5
  28. package/dist/classes/index.js +0 -5
  29. package/dist/classes/shardsUtil.d.ts +0 -40
  30. package/dist/classes/shardsUtil.js +0 -122
  31. package/dist/classes/utils.js +0 -28
  32. package/dist/constants/eventDatas.d.ts +0 -31
  33. package/dist/constants/eventDatas.js +0 -105
  34. package/dist/constants/index.js +0 -5
  35. package/dist/constants/shardsInfo.js +0 -424
  36. package/dist/constants/shardsTimeline.js +0 -46
  37. package/dist/typings.d.ts +0 -58
  38. package/dist/typings.js +0 -1
  39. package/dist/utils/index.d.ts +0 -5
  40. package/dist/utils/index.js +0 -5
  41. package/dist/utils/parseDateFormat.js +0 -25
  42. package/dist/utils/parsePerms.js +0 -54
  43. package/dist/utils/postToBin.js +0 -15
  44. package/dist/utils/recursiveReadDir.js +0 -37
  45. package/dist/utils/resolveColors.js +0 -63
  46. package/shared/assets/Point.png +0 -0
  47. package/shared/assets/Win.png +0 -0
  48. package/shared/assets/medal_champion_award_winner_olympic_icon_207790.png +0 -0
  49. package/shared/assets/server.svg +0 -41
  50. package/shared/fonts/circularstd-black.otf +0 -0
  51. package/shared/fonts/notoemoji-bold.ttf +0 -0
  52. package/shared/fonts/notosans-black.ttf +0 -0
  53. package/shared/fonts/notosans-jp-black.ttf +0 -0
  54. package/shared/fonts/notosans-kr-black.ttf +0 -0
@@ -1,122 +0,0 @@
1
- import { DateTime } from "luxon";
2
- import { shardsTimeline, shardConfig } from "../constants/index.js";
3
- /**
4
- * Sequence of Shards pattern
5
- */
6
- const shardSequence = ["C", "b", "A", "a", "B", "b", "C", "a", "A", "b", "B", "a"];
7
- /**
8
- * Sequence of realms pattern of shard
9
- */
10
- const realmSequence = ["prairie", "forest", "valley", "wasteland", "vault"];
11
- /**
12
- * @class shardsUtil
13
- * @classdesc A class to handle shards and realms indexing.
14
- */
15
- export class ShardsUtil {
16
- /**
17
- * @method getDate - get provided date in luxon
18
- * @param date - date to get in moment
19
- */
20
- static getDate(date) {
21
- const timezone = "America/Los_Angeles";
22
- let currentDate;
23
- try {
24
- if (date) {
25
- const [year, month, day] = date.split("-").map(Number);
26
- currentDate = DateTime.fromObject({ year, month, day }, { zone: timezone }).startOf("day");
27
- }
28
- else {
29
- currentDate = DateTime.now().setZone(timezone).startOf("day");
30
- }
31
- if (!currentDate.isValid) {
32
- return "invalid";
33
- }
34
- else {
35
- return currentDate;
36
- }
37
- }
38
- catch (error) {
39
- throw new Error(error);
40
- }
41
- }
42
- /**
43
- * Returns shards index for a given date
44
- * @param date
45
- */
46
- static shardsIndex(date) {
47
- const dayOfMonth = date.day;
48
- const shardIndex = (dayOfMonth - 1) % shardSequence.length;
49
- const currentShard = shardSequence[shardIndex];
50
- const realmIndex = (dayOfMonth - 1) % realmSequence.length;
51
- const currentRealm = realmSequence[realmIndex];
52
- return { currentShard, currentRealm };
53
- }
54
- /**
55
- * Returns suffix for a given number
56
- * @param number The number to get the suffix for
57
- */
58
- static getSuffix(number) {
59
- const suffixes = ["th", "st", "nd", "rd"];
60
- const remainder10 = number % 10;
61
- const remainder100 = number % 100;
62
- // Suffix for shards index
63
- return suffixes[remainder10 === 1 && remainder100 !== 11
64
- ? 1
65
- : remainder10 === 2 && remainder100 !== 12
66
- ? 2
67
- : remainder10 === 3 && remainder100 !== 13
68
- ? 3
69
- : 0];
70
- }
71
- /**
72
- * Get all three shards status for a given date relative to the current time
73
- * @param date The date for which to get the status for
74
- */
75
- static getStatus(date) {
76
- const timezone = "America/Los_Angeles";
77
- const { currentShard } = this.shardsIndex(date);
78
- const timings = shardsTimeline(date)[currentShard];
79
- const present = DateTime.now().setZone(timezone);
80
- const isNoShard = shardConfig[currentShard].weekdays.includes(date.weekday);
81
- if (isNoShard)
82
- return "No Shard";
83
- const toReturn = [];
84
- for (let i = 0; i < timings.length; i++) {
85
- const eventTiming = timings[i];
86
- // Active
87
- if (present >= eventTiming.start && present <= eventTiming.end) {
88
- toReturn.push({
89
- index: i + 1,
90
- active: true,
91
- start: eventTiming.start,
92
- end: eventTiming.end,
93
- duration: eventTiming.end.diff(present, ["days", "hours", "minutes", "seconds"]).toFormat("dd'd' hh'h' mm'm' ss's'"),
94
- });
95
- continue;
96
- // Yet to fall
97
- }
98
- else if (present < eventTiming.start) {
99
- toReturn.push({
100
- index: i + 1,
101
- active: false,
102
- start: eventTiming.start,
103
- end: eventTiming.end,
104
- duration: eventTiming.start.diff(present, ["days", "hours", "minutes", "seconds"]).toFormat("dd'd' hh'h' mm'm' ss's'"),
105
- });
106
- continue;
107
- // All ended
108
- }
109
- else if (present > eventTiming.end) {
110
- toReturn.push({
111
- index: i + 1,
112
- ended: true,
113
- start: eventTiming.start,
114
- end: eventTiming.end,
115
- duration: present.diff(eventTiming.end, ["days", "hours", "minutes", "seconds"]).toFormat("dd'd' hh'h' mm'm' ss's'"),
116
- });
117
- continue;
118
- }
119
- }
120
- return toReturn;
121
- }
122
- }
@@ -1,28 +0,0 @@
1
- import { CDNRoutes } from "discord-api-types/v10";
2
- export const colors = {
3
- blue: "#7289DA",
4
- white: "#FFFFFF",
5
- lightgrey: "#99AAB5",
6
- grey: "#2C2F33",
7
- darkgrey: "#23272A",
8
- black: "#000000",
9
- online: "#2db85b",
10
- offline: "#666",
11
- dnd: "#cc3737",
12
- idle: "#dab026",
13
- };
14
- export function fancyCount(n) {
15
- if (n > 1000000)
16
- return Math.floor(n / 1000000) + "M";
17
- if (n > 1000) {
18
- if (n < 10000)
19
- return (n / 1000).toFixed(1) + "k";
20
- return Math.floor(n / 1000) + "k";
21
- }
22
- return Math.floor(n) + "";
23
- }
24
- export function getUserAvatar(user) {
25
- return user.avatar
26
- ? CDNRoutes.userAvatar(user.id, user.avatar, "png")
27
- : CDNRoutes.defaultUserAvatar(Number((BigInt(user.id) >> 22n) % 5n));
28
- }
@@ -1,31 +0,0 @@
1
- export interface EventData {
2
- [key: string]: {
3
- /** Name of the event */
4
- name: string;
5
- /** The index of the event to appear on the embed */
6
- index: number;
7
- /** The Offset of the event (in minutes) */
8
- offset: number;
9
- /** Approximate duration of the event during which its active after it starts (in minutes) */
10
- duration?: number;
11
- /** The interval at which the event occurs (in minutes) */
12
- interval?: number;
13
- /** Whether to display all their occurrence times in the embed */
14
- displayAllTimes?: boolean;
15
- /** The days on which the event occurs */
16
- occursOn?: {
17
- /** Weekdays on which the event occurs */
18
- weekDays?: number[];
19
- /** The day on which the event occurs */
20
- dayOfTheMonth?: number;
21
- };
22
- /** Infographic related to the event, if any (Discord link)*/
23
- infographic?: {
24
- /** Credit */
25
- by: string;
26
- /** The guide */
27
- image: string;
28
- };
29
- };
30
- }
31
- export declare const eventData: EventData;
@@ -1,105 +0,0 @@
1
- const getMinutes = (hours) => hours * 60;
2
- export const eventData = {
3
- geyser: {
4
- name: "Geyser",
5
- index: 0,
6
- duration: 15,
7
- offset: 0,
8
- infographic: {
9
- by: "Clement",
10
- image: "https://media.discordapp.net/attachments/867638574571323424/1252998364941914243/Visit_Geyser_Clement.png?ex=66744129&is=6672efa9&hm=8d76d1767aca362d23547b1e3beb2b610f58e4fbec24b12af56fdc745f7074e8&",
11
- },
12
- displayAllTimes: true,
13
- interval: getMinutes(2),
14
- },
15
- grandma: {
16
- name: "Grandma",
17
- index: 1,
18
- duration: 15,
19
- offset: 30,
20
- infographic: {
21
- by: "Clement",
22
- image: "https://media.discordapp.net/attachments/867638574571323424/1252998366288416849/Visit_Grandma_Clement.png?ex=6674412a&is=6672efaa&hm=7228b695ec7008204fede2f3d6b4864a06a7cfa25a14ab4d7572957ee940044c&",
23
- },
24
- displayAllTimes: true,
25
- interval: getMinutes(2),
26
- },
27
- turtle: {
28
- name: "Turtle",
29
- index: 2,
30
- duration: 10,
31
- offset: 50,
32
- infographic: {
33
- by: "Velvet",
34
- image: "https://media.discordapp.net/attachments/867638574571323424/1252998363205472316/Visit_Turtle_Velvet.jpg?ex=66744129&is=6672efa9&hm=8c189ff8501fc88810606b832addbea8a9a81eb7a7a6b17019ff1ced593e1ae8&",
35
- },
36
- displayAllTimes: true,
37
- interval: getMinutes(2),
38
- },
39
- "daily-reset": {
40
- name: "Daily Reset",
41
- index: 3,
42
- offset: 0,
43
- interval: getMinutes(24),
44
- },
45
- eden: {
46
- name: "Eden/Weekly Reset",
47
- index: 4,
48
- offset: 0,
49
- interval: getMinutes(24 * 7),
50
- occursOn: { weekDays: [7] },
51
- },
52
- aurora: {
53
- name: "Aurora's concert",
54
- index: 5,
55
- offset: 0,
56
- duration: 50,
57
- displayAllTimes: true,
58
- interval: getMinutes(2),
59
- },
60
- "dream-skater": {
61
- name: "Dream Skater",
62
- index: 6,
63
- duration: 15,
64
- displayAllTimes: true,
65
- occursOn: { weekDays: [5, 6, 7] },
66
- offset: getMinutes(1),
67
- interval: getMinutes(2),
68
- },
69
- "passage-quests": {
70
- name: "Passage Quests",
71
- index: 7,
72
- offset: 0,
73
- displayAllTimes: true,
74
- interval: 15,
75
- },
76
- "nest-sunset": {
77
- name: "Nest Sunset",
78
- index: 8,
79
- offset: 40,
80
- displayAllTimes: true,
81
- interval: getMinutes(1),
82
- },
83
- "fireworks-festival": {
84
- name: "Fireworks Festival",
85
- index: 9,
86
- offset: 0,
87
- displayAllTimes: true,
88
- interval: getMinutes(4),
89
- occursOn: { dayOfTheMonth: 1 },
90
- },
91
- "fairy-ring": {
92
- name: "Fairy Ring",
93
- index: 11,
94
- offset: 50,
95
- displayAllTimes: true,
96
- interval: 60,
97
- },
98
- "brook-rainbow": {
99
- name: "Forest Brook Rainbow",
100
- index: 12,
101
- displayAllTimes: true,
102
- offset: getMinutes(5),
103
- interval: getMinutes(12),
104
- },
105
- };
@@ -1,5 +0,0 @@
1
- export * from "./shardsTimeline.js";
2
- export * from "./shardsInfo.js";
3
- export * from "./shardsInfo.js";
4
- export * from "./shardsTimeline.js";
5
- export * from "./eventDatas.js";