@skyhelperbot/utils 2.0.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 +21 -0
- package/README.md +11 -0
- package/dist/classes/LeaderBoardCard.d.ts +59 -0
- package/dist/classes/LeaderBoardCard.js +249 -0
- package/dist/classes/SkytimesUtils.d.ts +73 -0
- package/dist/classes/SkytimesUtils.js +119 -0
- package/dist/classes/UpdateEvent.d.ts +30 -0
- package/dist/classes/UpdateEvent.js +52 -0
- package/dist/classes/UpdateTs.d.ts +35 -0
- package/dist/classes/UpdateTs.js +62 -0
- package/dist/classes/WinnerCard.d.ts +13 -0
- package/dist/classes/WinnerCard.js +118 -0
- package/dist/classes/index.d.ts +7 -0
- package/dist/classes/index.js +7 -0
- package/dist/classes/shardsUtil.d.ts +41 -0
- package/dist/classes/shardsUtil.js +122 -0
- package/dist/classes/utils.d.ts +13 -0
- package/dist/classes/utils.js +22 -0
- package/dist/constants/eventDatas.d.ts +31 -0
- package/dist/constants/eventDatas.js +105 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/index.js +5 -0
- package/dist/constants/shardsInfo.d.ts +50 -0
- package/dist/constants/shardsInfo.js +424 -0
- package/dist/constants/shardsTimeline.d.ts +19 -0
- package/dist/constants/shardsTimeline.js +57 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/typings.d.ts +62 -0
- package/dist/typings.js +3 -0
- package/dist/utils/buildTimesHTML.d.ts +14 -0
- package/dist/utils/buildTimesHTML.js +208 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/parseDateFormat.d.ts +9 -0
- package/dist/utils/parseDateFormat.js +25 -0
- package/dist/utils/parsePerms.d.ts +49 -0
- package/dist/utils/parsePerms.js +54 -0
- package/dist/utils/postToBin.d.ts +5 -0
- package/dist/utils/postToBin.js +15 -0
- package/dist/utils/recursiveReadDir.d.ts +15 -0
- package/dist/utils/recursiveReadDir.js +37 -0
- package/package.json +44 -0
- package/shared/assets/Point.png +0 -0
- package/shared/assets/Win.png +0 -0
- package/shared/assets/medal_champion_award_winner_olympic_icon_207790.png +0 -0
- package/shared/assets/server.svg +41 -0
- package/shared/fonts/circularstd-black.otf +0 -0
- package/shared/fonts/notoemoji-bold.ttf +0 -0
- package/shared/fonts/notosans-black.ttf +0 -0
- package/shared/fonts/notosans-jp-black.ttf +0 -0
- package/shared/fonts/notosans-kr-black.ttf +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {} from "discord.js";
|
|
2
|
+
/**
|
|
3
|
+
* Dynamically builds a timestamp sweb page html with the given data
|
|
4
|
+
* @param interaction The interaction that intiated this
|
|
5
|
+
* @param fieldsData The data about times
|
|
6
|
+
* @param offset Offset of the timezone
|
|
7
|
+
* @param providedTime
|
|
8
|
+
*/
|
|
9
|
+
export const buildTimesHTML = (interaction, fieldsData, offset, providedTime) => {
|
|
10
|
+
return `
|
|
11
|
+
<!DOCTYPE html>
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<html lang="en">
|
|
15
|
+
|
|
16
|
+
<head>
|
|
17
|
+
<meta charset="UTF-8">
|
|
18
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
19
|
+
<!--=============== FAVICON ===============-->
|
|
20
|
+
<link rel="shortcut icon" href="/assets/img/boticon.png" type="image/x-icon">
|
|
21
|
+
|
|
22
|
+
<!--=============== BOXICONS ===============-->
|
|
23
|
+
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
|
|
24
|
+
|
|
25
|
+
<!--=============== SWIPER CSS ===============-->
|
|
26
|
+
<link rel="stylesheet" href="/assets/css/swiper-bundle.min.css">
|
|
27
|
+
|
|
28
|
+
<!--=============== CSS ===============-->
|
|
29
|
+
<link rel="stylesheet" href="/assets/css/styles.css">
|
|
30
|
+
|
|
31
|
+
<title>Timestamp - SkyHelper</title>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<!--==================== HEADER ====================-->
|
|
35
|
+
|
|
36
|
+
<header class="header" id="header">
|
|
37
|
+
|
|
38
|
+
<nav class="nav container">
|
|
39
|
+
<a href="/" class="nav__logo">
|
|
40
|
+
<img src="/assets/img/boticon.png" style="top: 50px; left: 50px; widht: 40px; height: 40px;"> <p class="nav__logo-text">SkyHelper</p>
|
|
41
|
+
</a>
|
|
42
|
+
<a href="/" class="nav__link">
|
|
43
|
+
|
|
44
|
+
<i class='bx bx-home-alt-2'></i>
|
|
45
|
+
<span>Home</span>
|
|
46
|
+
</a>
|
|
47
|
+
|
|
48
|
+
<!-- Theme change button -->
|
|
49
|
+
<i class='bx bx-moon change-theme' id="theme-button"></i>
|
|
50
|
+
<a href="/commands" class="nav__link">
|
|
51
|
+
<i class='bx bx-code-alt com-icon'></i><p class="nav__com">Commands</p>
|
|
52
|
+
</a>
|
|
53
|
+
<a href="https://discord.com/invite/u9zUjWbbQ4" class="button nav__button">
|
|
54
|
+
Invite Me
|
|
55
|
+
</a>
|
|
56
|
+
</nav>
|
|
57
|
+
</header>
|
|
58
|
+
|
|
59
|
+
<!-- Content -->
|
|
60
|
+
<main class="main">
|
|
61
|
+
<section class="home section" id="home">
|
|
62
|
+
<div class="home__container container grid">
|
|
63
|
+
<div class="home__data">
|
|
64
|
+
<h1 class="home__title">
|
|
65
|
+
Timestamp
|
|
66
|
+
</h1>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</section>
|
|
70
|
+
|
|
71
|
+
</main>
|
|
72
|
+
|
|
73
|
+
<!-- timestamp -->
|
|
74
|
+
<section class="value section" id="value">
|
|
75
|
+
<div class="value__container container times__data">
|
|
76
|
+
<h2 class="section__title">
|
|
77
|
+
Timestamp for <img src="${interaction.user.displayAvatarURL()}" style="width:25px;height:25px;border-radius:50%;"><span> ${interaction.user.username}</span>
|
|
78
|
+
</h2>
|
|
79
|
+
<div class="alert alert-info">Provided Time: ${providedTime}<br>Offset: <strong>${offset}</strong>
|
|
80
|
+
</div>
|
|
81
|
+
<div class="value__accordion-item2">
|
|
82
|
+
${fieldsData
|
|
83
|
+
.map((field) => `
|
|
84
|
+
|
|
85
|
+
<div class="time__header">
|
|
86
|
+
<strong>${field.name} (<span class="discUnix">${field.example}</span>)</strong></div>
|
|
87
|
+
|
|
88
|
+
<br> <span class="code-block">${sanitizeField(field.value)}</span> <button class="copyBtn">
|
|
89
|
+
<span><svg class ="copySvg" viewBox="0 0 467 512.22" clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" text-rendering="geometricPrecision" shape-rendering="geometricPrecision" xmlns="http://www.w3.org/2000/svg" height="12" width="12"><path d="M131.07 372.11c.37 1 .57 2.08.57 3.2 0 1.13-.2 2.21-.57 3.21v75.91c0 10.74 4.41 20.53 11.5 27.62s16.87 11.49 27.62 11.49h239.02c10.75 0 20.53-4.4 27.62-11.49s11.49-16.88 11.49-27.62V152.42c0-10.55-4.21-20.15-11.02-27.18l-.47-.43c-7.09-7.09-16.87-11.5-27.62-11.5H170.19c-10.75 0-20.53 4.41-27.62 11.5s-11.5 16.87-11.5 27.61v219.69zm-18.67 12.54H57.23c-15.82 0-30.1-6.58-40.45-17.11C6.41 356.97 0 342.4 0 326.52V57.79c0-15.86 6.5-30.3 16.97-40.78l.04-.04C27.51 6.49 41.94 0 57.79 0h243.63c15.87 0 30.3 6.51 40.77 16.98l.03.03c10.48 10.48 16.99 24.93 16.99 40.78v36.85h50c15.9 0 30.36 6.5 40.82 16.96l.54.58c10.15 10.44 16.43 24.66 16.43 40.24v302.01c0 15.9-6.5 30.36-16.96 40.82-10.47 10.47-24.93 16.97-40.83 16.97H170.19c-15.9 0-30.35-6.5-40.82-16.97-10.47-10.46-16.97-24.92-16.97-40.82v-69.78zM340.54 94.64V57.79c0-10.74-4.41-20.53-11.5-27.63-7.09-7.08-16.86-11.48-27.62-11.48H57.79c-10.78 0-20.56 4.38-27.62 11.45l-.04.04c-7.06 7.06-11.45 16.84-11.45 27.62v268.73c0 10.86 4.34 20.79 11.38 27.97 6.95 7.07 16.54 11.49 27.17 11.49h55.17V152.42c0-15.9 6.5-30.35 16.97-40.82 10.47-10.47 24.92-16.96 40.82-16.96h170.35z" fill-rule="nonzero"></path></svg> Copy</span>
|
|
90
|
+
<span>Copied</span>
|
|
91
|
+
</button>
|
|
92
|
+
<br><br>`)
|
|
93
|
+
.join("")}
|
|
94
|
+
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</section>
|
|
98
|
+
<!--==================== FOOTER ====================-->
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
<footer class="footer section">
|
|
103
|
+
|
|
104
|
+
<div class="footer__container container grid">
|
|
105
|
+
<div>
|
|
106
|
+
<a href="#" class="footer__logo">
|
|
107
|
+
<img src="/assets/img/boticon.png" style="top: 50px; left: 50px; widht: 20px; height: 20px;"> SkyHelper
|
|
108
|
+
</a>
|
|
109
|
+
<p class="footer__description">
|
|
110
|
+
A discord bot for the game Sky: Children of the Light
|
|
111
|
+
</p>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="footer__content">
|
|
114
|
+
<div>
|
|
115
|
+
<h3 class="footer__title">
|
|
116
|
+
About
|
|
117
|
+
</h3>
|
|
118
|
+
<ul class="footer__links">
|
|
119
|
+
<li>
|
|
120
|
+
<a href="/" class="footer__link">About Me</a>
|
|
121
|
+
</li>
|
|
122
|
+
|
|
123
|
+
<li>
|
|
124
|
+
|
|
125
|
+
<a href="/#popular" class="footer__link">Features</a>
|
|
126
|
+
|
|
127
|
+
</li>
|
|
128
|
+
<li>
|
|
129
|
+
|
|
130
|
+
<a href="https://docs.skyhelper.xyz" class="footer__link">Documentation</a>
|
|
131
|
+
|
|
132
|
+
</li>
|
|
133
|
+
</ul>
|
|
134
|
+
</div>
|
|
135
|
+
<div>
|
|
136
|
+
|
|
137
|
+
<h3 class="footer__title">
|
|
138
|
+
|
|
139
|
+
Support
|
|
140
|
+
</h3>
|
|
141
|
+
<ul class="footer__links">
|
|
142
|
+
<li>
|
|
143
|
+
<a href="/#value" class="footer__link">FAQs</a>
|
|
144
|
+
</li>
|
|
145
|
+
<li>
|
|
146
|
+
|
|
147
|
+
<a href="https://discord.com/invite/u9zUjWbbQ4" class="footer__link">Support Server</a>
|
|
148
|
+
|
|
149
|
+
</li>
|
|
150
|
+
<li>
|
|
151
|
+
|
|
152
|
+
<a href="/contact-us" class="footer__link">Contact Us</a>
|
|
153
|
+
|
|
154
|
+
</li>
|
|
155
|
+
</ul>
|
|
156
|
+
</div>
|
|
157
|
+
<div>
|
|
158
|
+
|
|
159
|
+
<h3 class="footer__title">
|
|
160
|
+
|
|
161
|
+
Socials
|
|
162
|
+
</h3>
|
|
163
|
+
<ul class="footer__social">
|
|
164
|
+
<a href="https://github.com/imnaiyar/SkyHelper" target="_blank" class="footer__social-link">
|
|
165
|
+
<i class='bx bxl-github'></i>
|
|
166
|
+
</a>
|
|
167
|
+
<a href="https://discord.com/invite/u9zUjWbbQ4" target="_blank" class="footer__social-link">
|
|
168
|
+
<i class='bx bxl-discord' ></i>
|
|
169
|
+
</a>
|
|
170
|
+
</ul>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<div class="footer__info container">
|
|
176
|
+
<span class="footer__copy">
|
|
177
|
+
© SkyHelper. All rights reserved
|
|
178
|
+
</span>
|
|
179
|
+
|
|
180
|
+
<div class="footer__privacy">
|
|
181
|
+
<a href="/tos">Terms of Service</a>
|
|
182
|
+
<a href="/privacy">Privacy Policy</a>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</footer>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<!--========== SCROLL UP ==========-->
|
|
189
|
+
<a href="#" class="scrollup" id="scroll-up">
|
|
190
|
+
<i class='bx bx-chevrons-up' ></i>
|
|
191
|
+
</a>
|
|
192
|
+
|
|
193
|
+
<!--=============== SCROLLREVEAL ===============-->
|
|
194
|
+
<script src="/assets/js/scrollreveal.min.js"></script>
|
|
195
|
+
|
|
196
|
+
<!--=============== SWIPER JS ===============-->
|
|
197
|
+
<script src="/assets/js/swiper-bundle.min.js"></script>
|
|
198
|
+
|
|
199
|
+
<!--=============== MAIN JS ===============-->
|
|
200
|
+
<script src="/assets/js/main.js"></script>
|
|
201
|
+
</body>
|
|
202
|
+
</html>
|
|
203
|
+
`;
|
|
204
|
+
};
|
|
205
|
+
function sanitizeField(value) {
|
|
206
|
+
// Remove backticks, <, and > characters
|
|
207
|
+
return value.replace(/`/g, "").replace(/</g, "<").replace(/>/g, ">");
|
|
208
|
+
}
|
|
@@ -0,0 +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";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a given date to it's format
|
|
3
|
+
* @param dateString The date to parse
|
|
4
|
+
* @example
|
|
5
|
+
* console.log(parseDateFormat("04/10/2024")) // Logs: DD/MM/YYYY
|
|
6
|
+
*
|
|
7
|
+
* @returns The format, or null if format can't be determined
|
|
8
|
+
*/
|
|
9
|
+
export declare const parseDateFormat: (dateString: string) => string | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a given date to it's format
|
|
3
|
+
* @param dateString The date to parse
|
|
4
|
+
* @example
|
|
5
|
+
* console.log(parseDateFormat("04/10/2024")) // Logs: DD/MM/YYYY
|
|
6
|
+
*
|
|
7
|
+
* @returns The format, or null if format can't be determined
|
|
8
|
+
*/
|
|
9
|
+
export const parseDateFormat = (dateString) => {
|
|
10
|
+
const formats = [
|
|
11
|
+
{ regex: /^\d{2}-\d{2}-\d{4}$/, format: "DD-MM-YYYY" },
|
|
12
|
+
{ regex: /^\d{2}\/\d{2}\/\d{4}$/, format: "DD/MM/YYYY" },
|
|
13
|
+
{ regex: /^\d{4}-\d{2}-\d{2}$/, format: "YYYY-MM-DD" },
|
|
14
|
+
{ regex: /^\d{4}\/\d{2}\/\d{2}$/, format: "YYYY/MM/DD" },
|
|
15
|
+
{ regex: /^\d{1,2}-\d{1,2}-\d{4}$/, format: "D-M-YYYY" },
|
|
16
|
+
{ regex: /^\d{1,2}\/\d{1,2}\/\d{4}$/, format: "D/M/YYYY" },
|
|
17
|
+
{ regex: /^[A-Za-z]+\s\d{1,2},\s\d{4}$/, format: "Month DD, YYYY" },
|
|
18
|
+
];
|
|
19
|
+
for (const { regex, format } of formats) {
|
|
20
|
+
if (regex.test(dateString)) {
|
|
21
|
+
return format;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null; // If no format matches
|
|
25
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
declare const permissions: {
|
|
2
|
+
readonly AddReactions: "Add Reactions";
|
|
3
|
+
readonly Administrator: "Administrator";
|
|
4
|
+
readonly AttachFiles: "Attach Files";
|
|
5
|
+
readonly BanMembers: "Ban Members";
|
|
6
|
+
readonly ChangeNickname: "Change Nickname";
|
|
7
|
+
readonly Connect: "Connect";
|
|
8
|
+
readonly CreateInstantInvite: "Create Instant Invite";
|
|
9
|
+
readonly CreatePrivateThreads: "Create Private Threads";
|
|
10
|
+
readonly CreatePublicThreads: "Create Public Threads";
|
|
11
|
+
readonly DeafenMembers: "Deafen Members";
|
|
12
|
+
readonly EmbedLinks: "Embed Links";
|
|
13
|
+
readonly KickMembers: "Kick Members";
|
|
14
|
+
readonly ManageChannels: "Manage Channels";
|
|
15
|
+
readonly ManageEmojisAndStickers: "Manage Emojis and Stickers";
|
|
16
|
+
readonly ManageEvents: "Manage Events";
|
|
17
|
+
readonly ManageGuild: "Manage Server";
|
|
18
|
+
readonly ManageMessages: "Manage Message";
|
|
19
|
+
readonly ManageNicknames: "Manage Nicknames";
|
|
20
|
+
readonly ManageRoles: "Manage Roles";
|
|
21
|
+
readonly ManageThreads: "Manage Threads";
|
|
22
|
+
readonly ManageWebhooks: "Manage Webhooks";
|
|
23
|
+
readonly MentionEveryone: "Mention Everyone";
|
|
24
|
+
readonly ModerateMembers: "Moderate Members";
|
|
25
|
+
readonly MoveMembers: "Move Members";
|
|
26
|
+
readonly MuteMembers: "Mute Members";
|
|
27
|
+
readonly PrioritySpeaker: "Priority Speaker";
|
|
28
|
+
readonly ReadMessageHistory: "Read Message History";
|
|
29
|
+
readonly RequestToSpeak: "Request to Speak";
|
|
30
|
+
readonly SendMessages: "Send messages";
|
|
31
|
+
readonly SendMessagesInThreads: "Send Messages In Threads";
|
|
32
|
+
readonly SendTTSMessages: "Send TTS messages";
|
|
33
|
+
readonly Speak: "Speak";
|
|
34
|
+
readonly Stream: "Video";
|
|
35
|
+
readonly UseApplicationCommands: "Use Application Commands";
|
|
36
|
+
readonly UseEmbeddedActivities: "Use Embedded Activities";
|
|
37
|
+
readonly UseExternalEmojis: "Use External Emojis";
|
|
38
|
+
readonly UseExternalStickers: "Use External Stickers";
|
|
39
|
+
readonly UseVAD: "Use Voice Activity";
|
|
40
|
+
readonly ViewAuditLog: "View Audit Log";
|
|
41
|
+
readonly ViewChannel: "View Channel";
|
|
42
|
+
readonly ViewGuildInsights: "View Server Insights";
|
|
43
|
+
};
|
|
44
|
+
export type Permission = keyof typeof permissions;
|
|
45
|
+
/**
|
|
46
|
+
* @param {string[]|string} perms
|
|
47
|
+
*/
|
|
48
|
+
export declare const parsePerms: (perms: Permission | Permission[]) => string;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const permissions = {
|
|
2
|
+
AddReactions: "Add Reactions",
|
|
3
|
+
Administrator: "Administrator",
|
|
4
|
+
AttachFiles: "Attach Files",
|
|
5
|
+
BanMembers: "Ban Members",
|
|
6
|
+
ChangeNickname: "Change Nickname",
|
|
7
|
+
Connect: "Connect",
|
|
8
|
+
CreateInstantInvite: "Create Instant Invite",
|
|
9
|
+
CreatePrivateThreads: "Create Private Threads",
|
|
10
|
+
CreatePublicThreads: "Create Public Threads",
|
|
11
|
+
DeafenMembers: "Deafen Members",
|
|
12
|
+
EmbedLinks: "Embed Links",
|
|
13
|
+
KickMembers: "Kick Members",
|
|
14
|
+
ManageChannels: "Manage Channels",
|
|
15
|
+
ManageEmojisAndStickers: "Manage Emojis and Stickers",
|
|
16
|
+
ManageEvents: "Manage Events",
|
|
17
|
+
ManageGuild: "Manage Server",
|
|
18
|
+
ManageMessages: "Manage Message",
|
|
19
|
+
ManageNicknames: "Manage Nicknames",
|
|
20
|
+
ManageRoles: "Manage Roles",
|
|
21
|
+
ManageThreads: "Manage Threads",
|
|
22
|
+
ManageWebhooks: "Manage Webhooks",
|
|
23
|
+
MentionEveryone: "Mention Everyone",
|
|
24
|
+
ModerateMembers: "Moderate Members",
|
|
25
|
+
MoveMembers: "Move Members",
|
|
26
|
+
MuteMembers: "Mute Members",
|
|
27
|
+
PrioritySpeaker: "Priority Speaker",
|
|
28
|
+
ReadMessageHistory: "Read Message History",
|
|
29
|
+
RequestToSpeak: "Request to Speak",
|
|
30
|
+
SendMessages: "Send messages",
|
|
31
|
+
SendMessagesInThreads: "Send Messages In Threads",
|
|
32
|
+
SendTTSMessages: "Send TTS messages",
|
|
33
|
+
Speak: "Speak",
|
|
34
|
+
Stream: "Video",
|
|
35
|
+
UseApplicationCommands: "Use Application Commands",
|
|
36
|
+
UseEmbeddedActivities: "Use Embedded Activities",
|
|
37
|
+
UseExternalEmojis: "Use External Emojis",
|
|
38
|
+
UseExternalStickers: "Use External Stickers",
|
|
39
|
+
UseVAD: "Use Voice Activity",
|
|
40
|
+
ViewAuditLog: "View Audit Log",
|
|
41
|
+
ViewChannel: "View Channel",
|
|
42
|
+
ViewGuildInsights: "View Server Insights",
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @param {string[]|string} perms
|
|
46
|
+
*/
|
|
47
|
+
export const parsePerms = (perms) => {
|
|
48
|
+
if (Array.isArray(perms)) {
|
|
49
|
+
return perms.map((perm) => `\`${permissions[perm]}\` `).join(", ");
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return `\`${permissions[perms] || perms}\``;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { request } from "undici";
|
|
2
|
+
/**
|
|
3
|
+
* Posts provided code to hastebin
|
|
4
|
+
* @param code
|
|
5
|
+
*/
|
|
6
|
+
export const postToHaste = async (code) => {
|
|
7
|
+
const req = await request("https://hst.sh/documents/", {
|
|
8
|
+
method: "POST",
|
|
9
|
+
body: typeof code === "object" ? JSON.stringify(code, null, 2) : code,
|
|
10
|
+
});
|
|
11
|
+
if (req.statusCode !== 200)
|
|
12
|
+
throw new Error("Status code did not return 200, something went wrong.");
|
|
13
|
+
const bin = await req.body.json();
|
|
14
|
+
return `https://hst.sh/${bin.key}.javascript`;
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param dir - the directory to read (from the root directory)
|
|
3
|
+
* @param skipDirectories The directories/sub-directories to skip
|
|
4
|
+
* @param allowedExtensions extension of the files to read
|
|
5
|
+
* @example
|
|
6
|
+
* const { reacursiveReadDir } = require('skyhelper-utils');
|
|
7
|
+
*
|
|
8
|
+
* const files = recursiveReadDir('src/commands');
|
|
9
|
+
* const commands = [];
|
|
10
|
+
* files.forEach((file) => {
|
|
11
|
+
* const command = require(file);
|
|
12
|
+
* commands.push(command.data.name, command);
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
export declare const recursiveReadDir: (dir: string, skipDirectories?: string[], allowedExtensions?: string[]) => string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { join, extname } from "path";
|
|
2
|
+
import { readdirSync, lstatSync } from "node:fs";
|
|
3
|
+
/**
|
|
4
|
+
* @param dir - the directory to read (from the root directory)
|
|
5
|
+
* @param skipDirectories The directories/sub-directories to skip
|
|
6
|
+
* @param allowedExtensions extension of the files to read
|
|
7
|
+
* @example
|
|
8
|
+
* const { reacursiveReadDir } = require('skyhelper-utils');
|
|
9
|
+
*
|
|
10
|
+
* const files = recursiveReadDir('src/commands');
|
|
11
|
+
* const commands = [];
|
|
12
|
+
* files.forEach((file) => {
|
|
13
|
+
* const command = require(file);
|
|
14
|
+
* commands.push(command.data.name, command);
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
17
|
+
export const recursiveReadDir = (dir, skipDirectories = [], allowedExtensions = [".js", ".ts"]) => {
|
|
18
|
+
const filePaths = [];
|
|
19
|
+
const readCommands = (direct) => {
|
|
20
|
+
const files = readdirSync(join(process.cwd(), direct));
|
|
21
|
+
files.forEach((file) => {
|
|
22
|
+
const stat = lstatSync(join(process.cwd(), direct, file));
|
|
23
|
+
if (stat.isDirectory() && !skipDirectories.includes(file)) {
|
|
24
|
+
readCommands(join(direct, file));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const extension = extname(file);
|
|
28
|
+
if (!allowedExtensions.includes(extension))
|
|
29
|
+
return;
|
|
30
|
+
const filePath = join(process.cwd(), direct, file);
|
|
31
|
+
filePaths.push(filePath);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
readCommands(dir);
|
|
36
|
+
return filePaths;
|
|
37
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@skyhelperbot/utils",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Utilities for SkyHelper bot",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc && echo 'Files compiled'",
|
|
10
|
+
"build:docs": "typedoc"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/imnaiyar/utils.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"SkyHelperUtils",
|
|
18
|
+
"Utility"
|
|
19
|
+
],
|
|
20
|
+
"imports": {},
|
|
21
|
+
"author": "NyR (Naiyar)",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*.js",
|
|
25
|
+
"dist/**/*.d.ts",
|
|
26
|
+
"shared/**/*"
|
|
27
|
+
],
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/imnaiyar/utils/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/imnaiyar/utils#readme",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@napi-rs/canvas": "^0.1.51",
|
|
34
|
+
"discord.js": "^14.14.1",
|
|
35
|
+
"moment-duration-format": "^2.3.2",
|
|
36
|
+
"moment-timezone": "^0.5.45",
|
|
37
|
+
"typescript": "^5.4.3",
|
|
38
|
+
"undici": "^6.13.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/moment-duration-format": "^2.2.6",
|
|
42
|
+
"mongoose": "^8.3.2"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:#FFFFFF;}
|
|
7
|
+
</style>
|
|
8
|
+
<g>
|
|
9
|
+
<g>
|
|
10
|
+
<g>
|
|
11
|
+
<path class="st0" d="M266.7,298.7h170.7c5.9,0,10.7-4.8,10.7-10.7s-4.8-10.7-10.7-10.7H266.7c-5.9,0-10.7,4.8-10.7,10.7
|
|
12
|
+
S260.8,298.7,266.7,298.7z"/>
|
|
13
|
+
<path class="st0" d="M512,202.7V160c0-10.3-3.1-19.8-8.1-28c-0.1-0.3-0.1-0.6-0.3-0.8l-66-106C427.8,9.4,410.9,0,392.3,0H119.7
|
|
14
|
+
c-18.6,0-35.5,9.4-45.3,25.2l-66,106c-0.1,0.2-0.1,0.4-0.3,0.7C3.1,140.1,0,149.7,0,160v42.7c0,17.5,8.6,32.9,21.7,42.7
|
|
15
|
+
C8.6,255.1,0,270.5,0,288v42.7c0,17.5,8.6,32.9,21.7,42.7C8.6,383.1,0,398.5,0,416v42.7C0,488.1,23.9,512,53.3,512h139.9
|
|
16
|
+
c5.9,0,10.7-4.8,10.7-10.7s-4.8-10.7-10.7-10.7H53.3c-17.6,0-32-14.4-32-32V416c0-17.7,14.4-32,32-32h178.4
|
|
17
|
+
c5.9,0,10.7-4.8,10.7-10.7s-4.8-10.7-10.7-10.7H53.3c-17.6,0-32-14.4-32-32V288c0-17.7,14.4-32,32-32h405.3c17.6,0,32,14.4,32,32
|
|
18
|
+
v42.7c0,4.7-1.2,9.4-3.4,14c-2.6,5.3-0.4,11.7,4.9,14.3c5.3,2.6,11.7,0.4,14.3-4.9c3.7-7.5,5.5-15.3,5.5-23.3V288
|
|
19
|
+
c0-17.5-8.6-32.9-21.7-42.7C503.4,235.6,512,220.2,512,202.7z M92.5,36.4c5.9-9.5,16-15.1,27.2-15.1h272.6
|
|
20
|
+
c11.1,0,21.3,5.7,27.2,15.1l44,70.7c-1.6-0.2-3.2-0.5-4.8-0.5H53.3c-1.6,0-3.2,0.3-4.8,0.5L92.5,36.4z M490.7,202.7
|
|
21
|
+
c0,17.6-14.4,32-32,32H53.3c-17.6,0-32-14.4-32-32V160c0-17.7,14.4-32,32-32h405.3c17.6,0,32,14.3,32,32L490.7,202.7L490.7,202.7
|
|
22
|
+
z"/>
|
|
23
|
+
<path class="st0" d="M42.7,437.3c0,17.6,14.4,32,32,32s32-14.4,32-32s-14.4-32-32-32S42.7,419.7,42.7,437.3z M85.3,437.3
|
|
24
|
+
c0,5.9-4.8,10.7-10.7,10.7S64,443.2,64,437.3s4.8-10.7,10.7-10.7S85.3,431.4,85.3,437.3z"/>
|
|
25
|
+
<path class="st0" d="M437.3,362.7c-1.9,0-3.9,0.1-5.8,0.3C413.8,336.3,383.9,320,352,320c-49.7,0-90.6,37.9-95.5,86.3
|
|
26
|
+
c-24.6,4.7-43.2,26.4-43.2,52.4c0,29.4,23.9,53.3,53.3,53.3h170.7c41.2,0,74.7-33.5,74.7-74.7S478.5,362.7,437.3,362.7z
|
|
27
|
+
M437.3,490.7H266.7c-17.6,0-32-14.4-32-32s14.4-32,32-32c5.9,0,10.7-4.8,10.7-10.7c0-41.2,33.5-74.7,74.7-74.7
|
|
28
|
+
c26.7,0,51.5,14.7,64.8,38.4c2.2,3.9,6.6,6,11.2,5.3c3.1-0.5,6.1-1,9.3-1c29.4,0,53.3,23.9,53.3,53.3S466.7,490.7,437.3,490.7z"
|
|
29
|
+
/>
|
|
30
|
+
<path class="st0" d="M437.3,149.3H266.7c-5.9,0-10.7,4.8-10.7,10.7s4.8,10.7,10.7,10.7h170.7c5.9,0,10.7-4.8,10.7-10.7
|
|
31
|
+
S443.2,149.3,437.3,149.3z"/>
|
|
32
|
+
<path class="st0" d="M437.3,192H266.7c-5.9,0-10.7,4.8-10.7,10.7s4.8,10.7,10.7,10.7h170.7c5.9,0,10.7-4.8,10.7-10.7
|
|
33
|
+
S443.2,192,437.3,192z"/>
|
|
34
|
+
<path class="st0" d="M74.7,149.3c-17.6,0-32,14.3-32,32s14.4,32,32,32s32-14.4,32-32C106.7,163.7,92.3,149.3,74.7,149.3z
|
|
35
|
+
M74.7,192c-5.9,0-10.7-4.8-10.7-10.7s4.8-10.7,10.7-10.7s10.7,4.8,10.7,10.7S80.6,192,74.7,192z"/>
|
|
36
|
+
<path class="st0" d="M42.7,309.3c0,17.6,14.4,32,32,32s32-14.4,32-32s-14.4-32-32-32S42.7,291.7,42.7,309.3z M85.3,309.3
|
|
37
|
+
c0,5.9-4.8,10.7-10.7,10.7S64,315.2,64,309.3s4.8-10.7,10.7-10.7S85.3,303.4,85.3,309.3z"/>
|
|
38
|
+
</g>
|
|
39
|
+
</g>
|
|
40
|
+
</g>
|
|
41
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|