ahegao 1.69.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.
@@ -0,0 +1,1370 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVALID_CHANNEL_NAME_CHARS_REGEX = exports.TRUE_KEYWORDS = exports.FALSE_KEYWORDS = exports.UWU_FACES = exports.CHECKMARK = exports.LIST_90_DEG = exports.REPLY_REFERENCE_MAX_LENGTH = exports.DISCORD_MESSAGE_LINKS_REGEX = exports.DISCORD_MESSAGE_LINK_REGEX = exports.FILLER_AND_NASTY_REGEX = exports.URL_REGEX = exports.USELESS_LINK_METADATA_REGEX = exports.DISCORD_USER_PING_REGEX = exports.DISCORD_ANY_PING_REGEX = exports.DISCORD_EMOJI_REGEX = exports.ONLY_TEXT_CHANNEL_SUPPORTED = exports.COMMAND_NOT_ALLOWED_IN_DEV_MESSAGE = exports.COMMAND_AT_START_OF_STRING_REGEX = exports.COMMAND_START_REGEX = exports.DYNAMIC_DATE_REGEX = exports.BLANK_RUNNABLE = void 0;
4
+ exports.math = math;
5
+ exports.calc = calc;
6
+ exports.formatNumber = formatNumber;
7
+ exports.scrollEmpty = scrollEmpty;
8
+ exports.defineWord = defineWord;
9
+ exports.makeEmbed = makeEmbed;
10
+ exports.makeMessage = makeMessage;
11
+ exports.makeEmbedMessage = makeEmbedMessage;
12
+ exports.isChannelThread = isChannelThread;
13
+ exports.makeGuildLink = makeGuildLink;
14
+ exports.makeChannelLink = makeChannelLink;
15
+ exports.makeMessageLinkFromMessage = makeMessageLinkFromMessage;
16
+ exports.makeMessageLink = makeMessageLink;
17
+ exports.makeEmbedTextAsLink = makeEmbedTextAsLink;
18
+ exports.userIdToPing = userIdToPing;
19
+ exports.objsToCommandChoices = objsToCommandChoices;
20
+ exports.objToCommandChoices = objToCommandChoices;
21
+ exports.asCommandChoices = asCommandChoices;
22
+ exports.getOrFromKeys = getOrFromKeys;
23
+ exports.commitSeppuku = commitSeppuku;
24
+ exports.getStringAsNumberOrDefault = getStringAsNumberOrDefault;
25
+ exports.getBooleanOrDefault = getBooleanOrDefault;
26
+ exports.newSet = newSet;
27
+ exports.getOrDefaultProperty = getOrDefaultProperty;
28
+ exports.isDev = isDev;
29
+ exports.isProduction = isProduction;
30
+ exports.sanitizeDiscordMessage = sanitizeDiscordMessage;
31
+ exports.unhideMessage = unhideMessage;
32
+ exports.isTextBasedChannel = isTextBasedChannel;
33
+ exports.isNotTextChannel = isNotTextChannel;
34
+ exports.getCuteName = getCuteName;
35
+ exports.getRandomHeartEmoji = getRandomHeartEmoji;
36
+ exports.getRandomPetname = getRandomPetname;
37
+ exports.getCuteIconUrl = getCuteIconUrl;
38
+ exports.getRandomUwuFace = getRandomUwuFace;
39
+ exports.getIsACommandString = getIsACommandString;
40
+ exports.getDontHavePermissionString = getDontHavePermissionString;
41
+ exports.getCuteNameForThisDay = getCuteNameForThisDay;
42
+ exports.getCuteIconUrlForThisDay = getCuteIconUrlForThisDay;
43
+ exports.getNameWhereOptions = getNameWhereOptions;
44
+ exports.getIdArrayWhereOptions = getIdArrayWhereOptions;
45
+ exports.getIdWhereOptions = getIdWhereOptions;
46
+ exports.getUserIdWhereOptions = getUserIdWhereOptions;
47
+ exports.getUserName = getUserName;
48
+ exports.getMemberName = getMemberName;
49
+ exports.getMemberNameOrElseUserName = getMemberNameOrElseUserName;
50
+ exports.getMemberNameOrElseUserNameFromMessage = getMemberNameOrElseUserNameFromMessage;
51
+ exports.getMemberNameOrElseUserNameFromInteraction = getMemberNameOrElseUserNameFromInteraction;
52
+ exports.makeClickableText = makeClickableText;
53
+ exports.updateChannelDescriptionIfDoesntMatch = updateChannelDescriptionIfDoesntMatch;
54
+ exports.isStringFalse = isStringFalse;
55
+ exports.isStringTrue = isStringTrue;
56
+ exports.attachmentsToUrls = attachmentsToUrls;
57
+ exports.attachmentsToFiles = attachmentsToFiles;
58
+ exports.attachmentsToRawFiles = attachmentsToRawFiles;
59
+ exports.messageToMessageCreateOptions = messageToMessageCreateOptions;
60
+ exports.toRainbowedAcronym = toRainbowedAcronym;
61
+ exports.itemToRainbowedAcronym = itemToRainbowedAcronym;
62
+ exports.messageToIdentifier = messageToIdentifier;
63
+ exports.toMessageIdentifier = toMessageIdentifier;
64
+ exports.toNameValueChoice = toNameValueChoice;
65
+ exports.toNameNumberValueOption = toNameNumberValueOption;
66
+ exports.toNameStringValueOption = toNameStringValueOption;
67
+ exports.toNameValueOption = toNameValueOption;
68
+ exports.forEachMessage = forEachMessage;
69
+ exports.offsetDate = offsetDate;
70
+ exports.newDate = newDate;
71
+ exports.dateToDynamicDate = dateToDynamicDate;
72
+ exports.msToDynamicDate = msToDynamicDate;
73
+ exports.sToDynamicDate = sToDynamicDate;
74
+ exports.getCannotAccessString = getCannotAccessString;
75
+ exports.getInvalidString = getInvalidString;
76
+ exports.getMissingString = getMissingString;
77
+ exports.getMissingIdString = getMissingIdString;
78
+ exports.getMissingContentString = getMissingContentString;
79
+ exports.getMissingCommandString = getMissingCommandString;
80
+ exports.getMissingSubCommandString = getMissingSubCommandString;
81
+ exports.getMissingSubCommandsCommandString = getMissingSubCommandsCommandString;
82
+ exports.getMissingNameString = getMissingNameString;
83
+ exports.getCheckOurDMsString = getCheckOurDMsString;
84
+ exports.getIDontKnowThisPersonString = getIDontKnowThisPersonString;
85
+ exports.getMessageCannotBeEmptyString = getMessageCannotBeEmptyString;
86
+ exports.bringRoleToTop = bringRoleToTop;
87
+ exports.renameGuildOrChannel = renameGuildOrChannel;
88
+ exports.renameMember = renameMember;
89
+ exports.rename = rename;
90
+ exports.hasBot = hasBot;
91
+ exports.hasUser = hasUser;
92
+ exports.hasUserId = hasUserId;
93
+ exports.hasAnyNotBot = hasAnyNotBot;
94
+ exports.hasEmojiByUserId = hasEmojiByUserId;
95
+ exports.setChannelPrivate = setChannelPrivate;
96
+ exports.sanitizeChannelName = sanitizeChannelName;
97
+ exports.channelMatches = channelMatches;
98
+ exports.getOrCreateTextChannel = getOrCreateTextChannel;
99
+ exports.getOrCreateThreadChannel = getOrCreateThreadChannel;
100
+ exports.getOrCreateCategory = getOrCreateCategory;
101
+ exports.getCategoryChannels = getCategoryChannels;
102
+ exports.discordCrossOut = discordCrossOut;
103
+ exports.discordUnderline = discordUnderline;
104
+ exports.discordBold = discordBold;
105
+ exports.dateFromDynamicDate = dateFromDynamicDate;
106
+ exports.referenceToUrl = referenceToUrl;
107
+ exports.react = react;
108
+ exports.parseDiscordMessageLinks = parseDiscordMessageLinks;
109
+ exports.parseFirstDiscordMessageLink = parseFirstDiscordMessageLink;
110
+ exports.isChannelPublic = isChannelPublic;
111
+ exports.messageToReference = messageToReference;
112
+ exports.messageLinkToReference = messageLinkToReference;
113
+ exports.getMessageById = getMessageById;
114
+ exports.wrapTitle = wrapTitle;
115
+ exports.isAttachmentSpoiler = isAttachmentSpoiler;
116
+ exports.isStringSpoiler = isStringSpoiler;
117
+ exports.messageToReplyString = messageToReplyString;
118
+ exports.timeAndUserIdToEmbedBuilder = timeAndUserIdToEmbedBuilder;
119
+ exports.filterUselessMetadata = filterUselessMetadata;
120
+ exports.isTextChannel = isTextChannel;
121
+ exports.embedToString = embedToString;
122
+ exports.getAllChannels = getAllChannels;
123
+ exports.arrayToDisplayUpToString = arrayToDisplayUpToString;
124
+ exports.debugLog = debugLog;
125
+ exports.backupToGit = backupToGit;
126
+ exports.getOrCreateRole = getOrCreateRole;
127
+ exports.getRoleById = getRoleById;
128
+ exports.tooLongForDiscord = tooLongForDiscord;
129
+ const discord_js_1 = require("discord.js");
130
+ const mathjs_1 = require("mathjs");
131
+ const path_1 = require("path");
132
+ const fields_1 = require("../types/fields");
133
+ const util_1 = require("./util");
134
+ const define = require("word-definition");
135
+ const BLANK_RUNNABLE = () => { };
136
+ exports.BLANK_RUNNABLE = BLANK_RUNNABLE;
137
+ exports.DYNAMIC_DATE_REGEX = /<t:([0-9]+)(?:\:[a-z])?>/i;
138
+ exports.COMMAND_START_REGEX = /(?:^|\s)(\.)[^\^\.!?_]/iu;
139
+ exports.COMMAND_AT_START_OF_STRING_REGEX = /^\.([a-z\p{L}])/iu;
140
+ exports.COMMAND_NOT_ALLOWED_IN_DEV_MESSAGE = `The bot is currently in Dev mode; This command is not available in Dev mode!`;
141
+ exports.ONLY_TEXT_CHANNEL_SUPPORTED = `Only TextChannel supported!`;
142
+ exports.DISCORD_EMOJI_REGEX = /([\w\d]+):(\d+)>/gmi;
143
+ exports.DISCORD_ANY_PING_REGEX = /<?@[^ ]+>?/ig;
144
+ exports.DISCORD_USER_PING_REGEX = /<@!?(\d+)>/g;
145
+ exports.USELESS_LINK_METADATA_REGEX = /(\?(ex|itmmeta)[^\n\r ]+)$/gi;
146
+ exports.URL_REGEX = /\bhttps?:\/\/\S+\b/gi;
147
+ exports.FILLER_AND_NASTY_REGEX = /(\bl+[oe]+l+\b|\b(h+e+){2,}\b|what the fuck|w+t+f+|rimming|cock|arse|arsing|f(?:uc)king|feck|jaysus|smegma|piss(?:ing)|jesus|l[oe]l[oel]+|seriously|stuff|victims?|honestly|my mans?|funny thing is|literally|you know it'?s serious when|gimps?|bron+(y+|i+e+s+)|bol+ock(s)?|xd+|trann(y|ies)|\bscat\b|farts?|sissy|n+[iⅰ]+[g𝗀]{2,}(a+|e+r+)|homies?|\bb+r+[u+e+]h+|lmf?ao|cring[e+y+]|dick|bussy|\bidk+|\bgtfo+|retards?|da+w+g+|ke+kw?|stinky|p+l+z+|s+h+i+t+y*|(smooth|huge|mega|big) +brain|brain +(damage)|fag|dickgirls?|futas?|ladyboys?|shemales?|pees? in (your|ur|my) \bass|🤓|🗿|dudet*e*s*|chad|god(?!ot)s?|to be honest)/gi;
148
+ exports.DISCORD_MESSAGE_LINK_REGEX = /https:\/\/discord\.com\/channels\/([0-9]+)\/([0-9]+)\/([0-9]+)/i;
149
+ exports.DISCORD_MESSAGE_LINKS_REGEX = new RegExp(exports.DISCORD_MESSAGE_LINK_REGEX, "gi");
150
+ exports.REPLY_REFERENCE_MAX_LENGTH = 152;
151
+ exports.LIST_90_DEG = "└";
152
+ const cuteNames = [
153
+ "Sunflower",
154
+ "Duckling",
155
+ "Lemon",
156
+ "Chick",
157
+ "Grapefruit",
158
+ "Puppy",
159
+ "Kitten",
160
+ "Avocado",
161
+ "Panda",
162
+ "Plum",
163
+ "Fawn",
164
+ "Pear",
165
+ "Clementine",
166
+ "Piglet",
167
+ "Kiwi",
168
+ "Sloth",
169
+ "Zucchini",
170
+ "Swan",
171
+ "Apricot",
172
+ "Puffin",
173
+ "Lychee",
174
+ "Guava",
175
+ "Llama",
176
+ "Nectarine",
177
+ "Pony",
178
+ "Starfruit",
179
+ "Peacock",
180
+ "Cranberry",
181
+ "Raspberry",
182
+ "Raccoon",
183
+ "Blackberry",
184
+ "Fig",
185
+ "Koala",
186
+ "Hazelnut",
187
+ "Walrus",
188
+ "Passionfruit",
189
+ "Salamander",
190
+ "Quokka",
191
+ "Dragonfruit",
192
+ "Hibiscus",
193
+ "Frog",
194
+ "Hummingbird",
195
+ "Lyrebird",
196
+ "Persimmon",
197
+ "Beaver",
198
+ "Cactus",
199
+ "Papaya",
200
+ "Pangolin",
201
+ "Peach",
202
+ "Platypus",
203
+ "Chestnut",
204
+ "Cheetah",
205
+ "Starfish",
206
+ "Flamingo",
207
+ "Jellyfish",
208
+ "Duck",
209
+ "Chickadee",
210
+ "Lime",
211
+ "Pigeon",
212
+ "Cucumber",
213
+ "Ferret",
214
+ "Beet",
215
+ "Broccoli",
216
+ "Parrot",
217
+ "Eggplant",
218
+ "Grape",
219
+ "Gazelle",
220
+ "Pomegranate",
221
+ "Penguin",
222
+ "Hedgehog",
223
+ "Toucan",
224
+ "Pumpkin",
225
+ "Zebra",
226
+ "Blossom",
227
+ "Pudding",
228
+ "Fluffy",
229
+ "Daisy",
230
+ "Sprinkle",
231
+ "Cinnamon",
232
+ "Honey",
233
+ "Honeybee",
234
+ "Honeybun",
235
+ "Snuggle",
236
+ "Buttercup",
237
+ "Sugarcube",
238
+ "Bubbles",
239
+ "Cupcake",
240
+ "Petal",
241
+ "Marshmallow",
242
+ "Peachy",
243
+ "Cookie",
244
+ "Lavender",
245
+ "Fuzzy",
246
+ "Bumble",
247
+ "Giggles",
248
+ "Peaches",
249
+ "Twinkle",
250
+ "Sparkle",
251
+ "Cherry",
252
+ "Jellybean",
253
+ "Rainbow",
254
+ "Daffodil",
255
+ "Sunny",
256
+ "Bubblegum",
257
+ "Precious",
258
+ "Sugarplum",
259
+ "Tulip",
260
+ "Melody",
261
+ "Angel",
262
+ "Stardust",
263
+ "Lulu",
264
+ "Fizzy",
265
+ "Candy",
266
+ "Clover",
267
+ "Glimmer",
268
+ "Sweets",
269
+ "Muffin",
270
+ "Bluebell",
271
+ "Pixie",
272
+ "Bunny",
273
+ "Peony",
274
+ "Poppy",
275
+ "Cupid",
276
+ "Rosy",
277
+ "Honey",
278
+ "Biscuit",
279
+ "Breezy",
280
+ "Sprinkles",
281
+ "Lollipop",
282
+ "Lullaby",
283
+ "Dizzy",
284
+ "Cuddlebug",
285
+ "Button",
286
+ "Moonbeam",
287
+ "Mellow",
288
+ "Dandelion",
289
+ "Doodlebug",
290
+ "Butterfly",
291
+ "Sweetpea",
292
+ "Whisper",
293
+ "Teddy",
294
+ "Luna",
295
+ "Coco",
296
+ "Pebble",
297
+ "Bambi",
298
+ "Mochi",
299
+ "Willow",
300
+ "Snowball",
301
+ "Chip",
302
+ "Socks",
303
+ "Hazel",
304
+ "Cotton",
305
+ "Ginger",
306
+ "Nibbles",
307
+ "Peanut",
308
+ "Marbles",
309
+ "Popcorn",
310
+ "Rosie",
311
+ "Buttons",
312
+ "Waffles",
313
+ "Acorn",
314
+ "Blueberry",
315
+ "Whiskers",
316
+ "Maple",
317
+ "Squeaky",
318
+ "Thistle",
319
+ "Pickles",
320
+ "Mopsy",
321
+ "Squeak",
322
+ "Basil",
323
+ "Sniffles",
324
+ "Doodle",
325
+ "Tippy",
326
+ "Nutmeg",
327
+ "Dazzle",
328
+ "Truffle",
329
+ "Apple",
330
+ "Jingle",
331
+ "Tinker",
332
+ "Flutter",
333
+ "Dreamer",
334
+ "Crystal",
335
+ "Twilight",
336
+ "Primrose",
337
+ "Peppermint",
338
+ "Breeze",
339
+ "Dewdrop",
340
+ "Starlight",
341
+ "Meadow",
342
+ "Misty",
343
+ "Lilypad",
344
+ "Rosebud",
345
+ "Starshine",
346
+ "Lily",
347
+ "Diamond",
348
+ "Sweetie",
349
+ "Bubble",
350
+ "Cloud",
351
+ "Sky",
352
+ "Snowflake",
353
+ "Spark",
354
+ "Dew",
355
+ "Feather",
356
+ "Star",
357
+ "Honeydew",
358
+ "Berry",
359
+ "Rose",
360
+ "Butter",
361
+ "Dream",
362
+ "Sunbeam",
363
+ "Starry",
364
+ "Glitter",
365
+ "Jewel",
366
+ "Cocoa",
367
+ "Emerald",
368
+ "Coral",
369
+ "Pearl",
370
+ "Minty",
371
+ "Ruby",
372
+ "Velvet",
373
+ "Violet",
374
+ "Wisp",
375
+ "Frost",
376
+ "Aurora",
377
+ "Jade",
378
+ "Puff",
379
+ "Sprite",
380
+ "Ivy",
381
+ "Nymph",
382
+ "Moss",
383
+ "Ember",
384
+ "Zephyr",
385
+ "Celestia",
386
+ "Evergreen",
387
+ "Opal",
388
+ "Cobweb",
389
+ "Starling",
390
+ "Marigold",
391
+ "Topaz",
392
+ "Flora",
393
+ "Cascade",
394
+ "Gossamer",
395
+ "Brook",
396
+ "Sorrel",
397
+ "Dusk",
398
+ "Fauna",
399
+ "Mist",
400
+ "Iris",
401
+ "Cuddle",
402
+ "Dreamy",
403
+ "Shimmer",
404
+ "Giggles",
405
+ "Pearl",
406
+ "Sugar",
407
+ "Sapphire",
408
+ "Twirl",
409
+ "Glimpse",
410
+ "Delight",
411
+ "Lacey",
412
+ "Celeste",
413
+ "Flicker",
414
+ "Taffy",
415
+ "Bliss",
416
+ "Gem",
417
+ ];
418
+ const genderNeutralPetnames = [
419
+ "Pumpkin",
420
+ "Sugar",
421
+ "Sugarcube",
422
+ "Honey",
423
+ "Sweetie",
424
+ "Cupcake",
425
+ "Buttercup",
426
+ "Jellybean",
427
+ "Marshmallow",
428
+ "Sweetie",
429
+ "Sweetheart",
430
+ "Darling",
431
+ "Love",
432
+ "Sugarplum",
433
+ "Sweetpea",
434
+ "Dear",
435
+ "Good Tomato",
436
+ "Silly Tomato",
437
+ "Sweet Tomato",
438
+ "Sunshine",
439
+ "Cutie Pie"
440
+ ];
441
+ const HEARTS_EMOJIS = [
442
+ "💖",
443
+ "💝",
444
+ "<:pinku_two_hearts:1050421227711373323>",
445
+ "<:pinkuheart:1046374855756492871>",
446
+ "<:growing_heart_1:1251486909239263242>",
447
+ "<:growing_heart_2:1251486906785468518>",
448
+ "<:heart_ribbon_1:1251486509480022066>",
449
+ "<:heart_ribbon_2:1251486506657386517>",
450
+ "<:pink_heart_1:1251486508351881297>",
451
+ "<:pink_heart_2:1251486505046769675>",
452
+ "<:pink_heart_3:1251486502630719499>",
453
+ "<:pink_heart_4:1251486499321548894>",
454
+ "<:revolving_hearts_1:1251486565004214272>",
455
+ "<:sparkling_heart_1:1251486904281727036>",
456
+ "<:sparkling_heart_2:1251486566052925441>",
457
+ "<:two_hearts_1:1251486503725568031>",
458
+ "<:two_hearts_2:1251486501057990667>",
459
+ "<:two_hearts_3:1251486907892891709>",
460
+ "<:two_hearts_4:1251486905623646248>",
461
+ "<:two_hearts_5:1251486902960525392>",
462
+ ];
463
+ exports.CHECKMARK = "✅";
464
+ exports.UWU_FACES = [">w<", "owo", "OwO", "uwu"];
465
+ const cuteIconLinks = [
466
+ //flower
467
+ "https://s3.amazonaws.com/pix.iemoji.com/andr33/0251.png",
468
+ "https://s3.amazonaws.com/pix.iemoji.com/hang33/0251.png",
469
+ "https://s3.amazonaws.com/pix.iemoji.com/twit33/0251.png",
470
+ "https://s3.amazonaws.com/pix.iemoji.com/lg33/0251.png",
471
+ "https://s3.amazonaws.com/pix.iemoji.com/sams33/0251.png",
472
+ //sparkles
473
+ "https://s3.amazonaws.com/pix.iemoji.com/andr33/0136.png",
474
+ "https://s3.amazonaws.com/pix.iemoji.com/hang33/0136.png",
475
+ "https://s3.amazonaws.com/pix.iemoji.com/twit33/0136.png",
476
+ "https://s3.amazonaws.com/pix.iemoji.com/lg33/0136.png",
477
+ "https://s3.amazonaws.com/pix.iemoji.com/sams33/0136.png",
478
+ //glowing star
479
+ "https://s3.amazonaws.com/pix.iemoji.com/andr33/0242.png",
480
+ "https://s3.amazonaws.com/pix.iemoji.com/hang33/0242.png",
481
+ "https://s3.amazonaws.com/pix.iemoji.com/twit33/0242.png",
482
+ "https://s3.amazonaws.com/pix.iemoji.com/lg33/0242.png",
483
+ "https://s3.amazonaws.com/pix.iemoji.com/sams33/0242.png",
484
+ "https://s3.amazonaws.com/pix.iemoji.com/phan33/0242.png",
485
+ //star
486
+ "https://s3.amazonaws.com/pix.iemoji.com/andr33/0161.png",
487
+ "https://s3.amazonaws.com/pix.iemoji.com/hang33/0161.png",
488
+ "https://s3.amazonaws.com/pix.iemoji.com/twit33/0161.png",
489
+ "https://s3.amazonaws.com/pix.iemoji.com/lg33/0161.png",
490
+ //hibiscus
491
+ "https://s3.amazonaws.com/pix.iemoji.com/andr33/0253.png",
492
+ "https://s3.amazonaws.com/pix.iemoji.com/hang33/0253.png",
493
+ "https://s3.amazonaws.com/pix.iemoji.com/twit33/0253.png",
494
+ "https://s3.amazonaws.com/pix.iemoji.com/lg33/0253.png",
495
+ "https://s3.amazonaws.com/pix.iemoji.com/sams33/0253.png",
496
+ ];
497
+ exports.FALSE_KEYWORDS = new Set([
498
+ "off",
499
+ "disable",
500
+ "disabled",
501
+ "false",
502
+ "0",
503
+ "no",
504
+ ]);
505
+ exports.TRUE_KEYWORDS = new Set([
506
+ "on",
507
+ "enable",
508
+ "enabled",
509
+ "true",
510
+ "1",
511
+ "yes",
512
+ ]);
513
+ ////////////////////////////////////////////////////////////////////////////////////
514
+ function math(args, id, givenType, minutes) {
515
+ let number = calc(args, minutes);
516
+ return formatNumber(number, id, givenType);
517
+ }
518
+ function calc(args, minutes) {
519
+ let toAdd = args.toString().toLowerCase()
520
+ .replace(/,/g, '.')
521
+ // .replace(/s/g, ``)
522
+ .replace(/k/g, `(1000)`)
523
+ .replace(/m/g, `(${minutes ? '60' : '1000000'})`)
524
+ .replace(/b/g, `(1000000000)`)
525
+ .replace(/h/g, `(3600)`)
526
+ .replace(/d/g, `(86400)`)
527
+ .replace(/w/g, `(604800)`)
528
+ .replace(/y/g, `(31536000)`)
529
+ .replace(/x10\^/g, 'e+')
530
+ .replace(/\*10\^/g, 'e+')
531
+ .replace(/x10\^-/g, 'e-')
532
+ .replace(/\*10\^-/g, 'e-')
533
+ .replace(/x/g, '*');
534
+ let temp = toAdd;
535
+ toAdd = toAdd.replace(/[a-d]/g, '').replace(/[f-z]/g, '');
536
+ if (toAdd != temp)
537
+ return NaN;
538
+ try {
539
+ return (0, mathjs_1.evaluate)(toAdd);
540
+ }
541
+ catch (e) {
542
+ return NaN;
543
+ }
544
+ }
545
+ function formatNumber(number, id, givenType) {
546
+ let type = givenType ? givenType : 'exponent';
547
+ try {
548
+ let isNegative = false;
549
+ if (number < 0) {
550
+ isNegative = true;
551
+ number = -number;
552
+ }
553
+ if (type == 'auto') {
554
+ if (number < 1000)
555
+ type = 'full';
556
+ else if (number < 1000000)
557
+ type = 'k';
558
+ else if (number < 1000000000)
559
+ type = 'm';
560
+ else if (number < 1000000000000)
561
+ type = 'b';
562
+ else if (number < 1000000000000000)
563
+ type = 't';
564
+ }
565
+ let final;
566
+ switch (type) {
567
+ case "exponent":
568
+ final = (0, mathjs_1.format)(number);
569
+ break;
570
+ case 'full':
571
+ final = (0, mathjs_1.format)(number, { precision: 16, lowerExp: -1000, upperExp: 1000 });
572
+ break;
573
+ // case 'med':
574
+ // final = format(number, {precision: 4, lowerExp: -9, upperExp: 9})
575
+ // break
576
+ // case 'low':
577
+ // final = format(number, {precision: 4, lowerExp: -2, upperExp: 3})
578
+ break;
579
+ case 'k':
580
+ final = (0, mathjs_1.format)(number / 1000, { precision: 3, lowerExp: -1000, upperExp: 1000 }) + 'k';
581
+ break;
582
+ case 'm':
583
+ final = (0, mathjs_1.format)(number / 1000000, { precision: 3, lowerExp: -1000, upperExp: 1000 }) + 'm';
584
+ break;
585
+ case 'b':
586
+ final = (0, mathjs_1.format)(number / 1000000000, { precision: 3, lowerExp: -1000, upperExp: 1000 }) + 'b';
587
+ break;
588
+ case 't':
589
+ final = (0, mathjs_1.format)(number / 1000000000000, { precision: 3, lowerExp: -1000, upperExp: 1000 }) + 't';
590
+ break;
591
+ default:
592
+ final = (0, mathjs_1.format)(number, { precision: 16, lowerExp: -4, upperExp: 5 });
593
+ break;
594
+ }
595
+ if (isNegative)
596
+ return `-${final}`;
597
+ else
598
+ return final;
599
+ }
600
+ catch (e) {
601
+ return "" + number;
602
+ }
603
+ }
604
+ // export function map(input: number, min1: number, max1: number, min2: number, max2: number): number
605
+ // {
606
+ // return parseFloat(math(((input - min1) / (max1 - min1)) * (max2 - min2) + min2, null, "raw"))
607
+ // }
608
+ function scrollEmpty(scrollAmount = 50) {
609
+ scrollAmount = (0, mathjs_1.min)(100, scrollAmount);
610
+ let output = `\`\`\``;
611
+ for (let i = 0; i < scrollAmount; ++i) {
612
+ output += `${fields_1.EMPTY}\n`;
613
+ }
614
+ output += `\`\`\``;
615
+ return output;
616
+ }
617
+ async function defineWord(word, lang) {
618
+ return new Promise((resolve, reject) => {
619
+ define.getDef(word, lang, null, (def) => {
620
+ if (def.error)
621
+ resolve({ definition: def.error });
622
+ if (def.definition == undefined)
623
+ resolve({ definition: `No definition found for the word: [${word}]. [${lang}]` });
624
+ resolve({ category: def.category, definition: def.definition });
625
+ });
626
+ });
627
+ }
628
+ function makeEmbed(title, description, color) {
629
+ if (title.length + description.length > 4096) {
630
+ console.log(util_1.chalk.redBright(`Longer than 4096 embed with ${title.length + description.length} length!\ntitle: ${title}\ndescription: ${description}`));
631
+ }
632
+ let embedColor = 0xff008D;
633
+ if (color) {
634
+ embedColor = color;
635
+ }
636
+ return new discord_js_1.EmbedBuilder()
637
+ .setTitle(title.length > 0 ? title : fields_1.EMPTY)
638
+ .setDescription(description.length > 0 ? description : fields_1.EMPTY)
639
+ .setColor(embedColor);
640
+ }
641
+ function makeMessage(embeds) {
642
+ if (Array.isArray(embeds))
643
+ return { embeds: embeds };
644
+ else
645
+ return { embeds: [embeds] };
646
+ }
647
+ function makeEmbedMessage(title, description, color) {
648
+ return makeMessage(makeEmbed(title, description, color));
649
+ }
650
+ function isChannelThread(channel) {
651
+ return channel.type == discord_js_1.ChannelType.PublicThread
652
+ || channel.type == discord_js_1.ChannelType.PrivateThread
653
+ || channel.type == discord_js_1.ChannelType.AnnouncementThread;
654
+ }
655
+ function makeGuildLink(guildId) {
656
+ return `https://discord.com/channels/${guildId}`;
657
+ }
658
+ function makeChannelLink(guildId, channelId) {
659
+ return `${makeGuildLink(guildId)}/${channelId}`;
660
+ }
661
+ function makeMessageLinkFromMessage(message) {
662
+ return makeMessageLink(message.guildId, message.channelId, message.id);
663
+ }
664
+ function makeMessageLink(guildId, channelId, messageId) {
665
+ if (guildId == null) {
666
+ return makeChannelLink(channelId, messageId);
667
+ }
668
+ return `${makeChannelLink(guildId, channelId)}/${messageId}`;
669
+ }
670
+ function makeEmbedTextAsLink(text, link) {
671
+ return `[${text}](${link})`;
672
+ }
673
+ function userIdToPing(userId) {
674
+ return `<@${userId}>`;
675
+ }
676
+ function objsToCommandChoices(objs, nameGetter, valueGetter) {
677
+ return (0, util_1.mapToArray)(objs, obj => objToCommandChoices(obj, nameGetter, valueGetter));
678
+ }
679
+ function objToCommandChoices(obj, nameGetter, valueGetter) {
680
+ return { name: nameGetter(obj), value: valueGetter(obj) };
681
+ }
682
+ function asCommandChoices(keys) {
683
+ const choices = [];
684
+ let i = 0;
685
+ for (const key of keys) {
686
+ if (++i == 25) {
687
+ console.log(`Warning: could only fit ${keys} keys as command choice`);
688
+ return choices;
689
+ }
690
+ choices.push({ name: key.toString(), value: key });
691
+ }
692
+ return choices;
693
+ }
694
+ function getOrFromKeys(stringCount, keyName) {
695
+ const orData = [{}];
696
+ delete orData[0];
697
+ for (const str of Object.keys(stringCount)) {
698
+ orData.push({
699
+ [keyName]: str
700
+ });
701
+ }
702
+ return orData;
703
+ }
704
+ function commitSeppuku() {
705
+ setTimeout(() => [1], 1523);
706
+ }
707
+ function getStringAsNumberOrDefault(interaction, name, defaultValue) {
708
+ const optionalValue = interaction.options.get(name);
709
+ if (optionalValue == null)
710
+ return defaultValue;
711
+ const calcResult = calc(optionalValue.value, true);
712
+ return isNaN(calcResult) ? defaultValue : calcResult;
713
+ }
714
+ function getBooleanOrDefault(interaction, name, defaultValue) {
715
+ const optionalValue = interaction.options.get(name);
716
+ if (optionalValue == null)
717
+ return defaultValue;
718
+ return optionalValue.value;
719
+ }
720
+ function newSet(collection) {
721
+ const values = new Set();
722
+ collection.forEach(guild => values.add(guild));
723
+ return values;
724
+ }
725
+ function getOrDefaultProperty(interaction, key, defaultValue) {
726
+ const valueOptional = interaction.options.get(key);
727
+ return valueOptional ? valueOptional.value : defaultValue;
728
+ }
729
+ function isDev() {
730
+ return process.env.ENVIRONMENT == "dev";
731
+ }
732
+ function isProduction() {
733
+ return process.env.ENVIRONMENT == "production";
734
+ }
735
+ function sanitizeDiscordMessage(message, hideFiller = false) {
736
+ message = message.replaceAll(exports.DISCORD_ANY_PING_REGEX, "[REMOVED PING]");
737
+ if (hideFiller) {
738
+ message = message.replaceAll(exports.FILLER_AND_NASTY_REGEX, "||$1||");
739
+ }
740
+ return message.trim().slice(0, fields_1.DISCORD_MESSAGE_LENGTH_LIMIT);
741
+ }
742
+ function unhideMessage(url) {
743
+ let startIndex = 0;
744
+ while (startIndex < url.length && (url[startIndex] === "|" || url[startIndex] === "<")) {
745
+ ++startIndex;
746
+ }
747
+ let endIndex = url.length;
748
+ while (endIndex > 0 && (url[endIndex - 1] === "|" || url[endIndex - 1] === ">")) {
749
+ --endIndex;
750
+ }
751
+ return url.substring(startIndex, endIndex);
752
+ }
753
+ function isTextBasedChannel(channel) {
754
+ if (channel instanceof discord_js_1.TextChannel) {
755
+ return true;
756
+ }
757
+ if (channel instanceof discord_js_1.ThreadChannel) {
758
+ return true;
759
+ }
760
+ return false;
761
+ }
762
+ function isNotTextChannel(channel) {
763
+ if (channel instanceof discord_js_1.TextChannel) {
764
+ return false;
765
+ }
766
+ if (channel instanceof discord_js_1.ThreadChannel) {
767
+ return false;
768
+ }
769
+ return true;
770
+ }
771
+ function getCuteName(index) {
772
+ return cuteNames[index % cuteNames.length];
773
+ }
774
+ function getRandomHeartEmoji(amount = 1) {
775
+ let emojis = "";
776
+ for (let i = 0; i < amount; ++i) {
777
+ emojis += (0, util_1.randomFromArray)(HEARTS_EMOJIS);
778
+ }
779
+ return emojis;
780
+ }
781
+ function getRandomPetname() {
782
+ return `${(0, util_1.randomFromArray)(genderNeutralPetnames)} ${getRandomHeartEmoji()}`;
783
+ }
784
+ function getCuteIconUrl(index) {
785
+ return cuteIconLinks[index % cuteIconLinks.length];
786
+ }
787
+ function getRandomUwuFace() {
788
+ return (0, util_1.randomFromArray)(exports.UWU_FACES);
789
+ }
790
+ function getIsACommandString(word) {
791
+ return `${wrapTitle(word)} is a command, ${getRandomPetname()}!`;
792
+ }
793
+ function getDontHavePermissionString() {
794
+ return `Excuse me ${getRandomPetname()}, but you don't have the permission to do this!`;
795
+ }
796
+ function getCuteNameForThisDay(user) {
797
+ return getCuteName((0, mathjs_1.floor)(parseInt(user.id) / (0, util_1.getDaySince1980)()));
798
+ }
799
+ function getCuteIconUrlForThisDay(user) {
800
+ return getCuteIconUrl((0, mathjs_1.floor)(parseInt(user.id) / (0, util_1.getDaySince1980)()));
801
+ }
802
+ function getNameWhereOptions(name) {
803
+ return { where: { name } };
804
+ }
805
+ function getIdArrayWhereOptions(ids) {
806
+ return { where: { id: { in: ids } } };
807
+ }
808
+ function getIdWhereOptions(id) {
809
+ return { where: { id } };
810
+ }
811
+ function getUserIdWhereOptions(userId) {
812
+ return { where: { userId } };
813
+ }
814
+ // export function getUser_idOptions(user_id: bigint): { where: { user_id: bigint } }
815
+ // {
816
+ // return { where: { user_id } }
817
+ // }
818
+ function getUserName(user) {
819
+ if (user == null) {
820
+ return fields_1.EMPTY;
821
+ }
822
+ if (user instanceof discord_js_1.GuildMember) {
823
+ if (user.nickname != null) {
824
+ return user.nickname;
825
+ }
826
+ else {
827
+ return user.displayName;
828
+ }
829
+ }
830
+ return (0, util_1.orElse)(user.globalName, () => (0, util_1.orElse)(user.username, () => user.displayName));
831
+ }
832
+ function getMemberName(member) {
833
+ return (0, util_1.orElse)(member.nickname, () => member.displayName);
834
+ }
835
+ function getMemberNameOrElseUserName(member, user) {
836
+ if (member == null) {
837
+ return getUserName(user);
838
+ }
839
+ return getMemberName(member);
840
+ }
841
+ function getMemberNameOrElseUserNameFromMessage(message) {
842
+ return getMemberNameOrElseUserName(message.member, message.author);
843
+ }
844
+ function getMemberNameOrElseUserNameFromInteraction(interaction) {
845
+ return getMemberNameOrElseUserName(interaction.member, interaction.user);
846
+ }
847
+ function makeClickableText(text, url) {
848
+ return `[${text}](${url})`;
849
+ }
850
+ async function updateChannelDescriptionIfDoesntMatch(channel, description) {
851
+ if (channel.topic != description) {
852
+ await channel.setTopic(description);
853
+ return true;
854
+ }
855
+ return false;
856
+ }
857
+ function isStringFalse(text) {
858
+ return exports.FALSE_KEYWORDS.has(text.trim().toLowerCase());
859
+ }
860
+ function isStringTrue(text) {
861
+ return exports.TRUE_KEYWORDS.has(text.trim().toLowerCase());
862
+ }
863
+ function attachmentsToUrls(attachments) {
864
+ let files = [];
865
+ for (const attachment of attachments.values()) {
866
+ files.push(attachment.url);
867
+ }
868
+ return files;
869
+ }
870
+ function attachmentsToFiles(attachments) {
871
+ let files = [];
872
+ for (const attachment of attachments.values()) {
873
+ files.push(isAttachmentSpoiler(attachment) ? `||${attachment.url}||` : attachment.url);
874
+ }
875
+ return files;
876
+ }
877
+ function attachmentsToRawFiles(attachments) {
878
+ let files = [];
879
+ for (const attachment of attachments.values()) {
880
+ files.push({ name: attachment.name, contentType: attachment.contentType, data: attachment.url });
881
+ files.push(Object.assign(Object.assign({}, attachment), { data: attachment.url }));
882
+ }
883
+ return files;
884
+ }
885
+ function messageToMessageCreateOptions(message) {
886
+ const files = attachmentsToFiles(message.attachments);
887
+ const messageCreateOptions = {
888
+ content: message.content,
889
+ files,
890
+ // reply: { messageReference: message?.reference?.messageId, failIfNotExists: false },
891
+ };
892
+ return messageCreateOptions;
893
+ }
894
+ function toRainbowedAcronym(name, key) {
895
+ const acronym = (0, util_1.acronymStringIfTooLong)(name);
896
+ if (acronym.length == 0) {
897
+ return "";
898
+ }
899
+ const seed = key ? parseInt(key) : (0, util_1.hashCode)(name);
900
+ return (0, util_1.chalkRainbowColor)(acronym, seed);
901
+ }
902
+ function itemToRainbowedAcronym(item) {
903
+ return item ? toRainbowedAcronym(item.name, item.id) : "";
904
+ }
905
+ function messageToIdentifier(message) {
906
+ return toMessageIdentifier(message.guild, message.channel, message.author);
907
+ }
908
+ function toMessageIdentifier(guild, channel, author) {
909
+ var _a;
910
+ let channelText = "";
911
+ if (channel != null) {
912
+ let channelType = channel.type;
913
+ let channelTypeStr = discord_js_1.ChannelType[channelType];
914
+ const channelName = (_a = channel["name"]) !== null && _a !== void 0 ? _a : channel.id;
915
+ const channelNameAcronym = toRainbowedAcronym(channelName, channel.id);
916
+ channelText = `[${toRainbowedAcronym(channelTypeStr)}][${channelNameAcronym.length == 0 ? channelName : channelNameAcronym}]`;
917
+ }
918
+ return `${guild == null ? "" : `[${itemToRainbowedAcronym(guild)}]`}${channelText}${author ? ` ${(0, util_1.chalkRainbowColor)(getUserName(author), parseInt(author.id))}` : ""}`;
919
+ }
920
+ function toNameValueChoice(text) {
921
+ const words = text.split(/[ _]/).filter(word => word.length >= 0);
922
+ let name = "";
923
+ let i = 0;
924
+ for (const word of words) {
925
+ if (i > 0) {
926
+ name += " ";
927
+ }
928
+ name += (0, util_1.firstUpperLowerRest)(word);
929
+ ++i;
930
+ }
931
+ return { name, value: text.toLowerCase().replaceAll(" ", "_") };
932
+ }
933
+ function toNameNumberValueOption(text, description, required = false) {
934
+ return toNameValueOption(text, discord_js_1.ApplicationCommandOptionType.Number, description, required);
935
+ }
936
+ function toNameStringValueOption(text, description, required = false) {
937
+ return toNameValueOption(text, discord_js_1.ApplicationCommandOptionType.String, description, required);
938
+ }
939
+ function toNameValueOption(text, type, description, required = false) {
940
+ const words = text.split(/[ _]/).filter(word => word.length >= 0);
941
+ let name = "";
942
+ let i = 0;
943
+ for (const word of words) {
944
+ if (i > 0) {
945
+ name += " ";
946
+ }
947
+ name += (0, util_1.firstUpperLowerRest)(word);
948
+ ++i;
949
+ }
950
+ return {
951
+ name: name.toLowerCase().replaceAll(" ", "_"),
952
+ description: description == null ? `The ${name}` : description,
953
+ type,
954
+ required,
955
+ };
956
+ }
957
+ async function forEachMessage(channel, consumer, referenceMsg, after = false) {
958
+ let fetchPointer = referenceMsg != null ? referenceMsg : await channel.messages
959
+ .fetch({ limit: 1 })
960
+ .then(messagePage => (messagePage.size === 1 ? messagePage.at(0) : null));
961
+ if (fetchPointer != null && await consumer(fetchPointer)) {
962
+ return;
963
+ }
964
+ let earlyExit = false;
965
+ let page = 1;
966
+ let messageCount = 0;
967
+ while (fetchPointer && !earlyExit) {
968
+ const fetchParamaters = { limit: 100 };
969
+ if (after) {
970
+ fetchParamaters["after"] = fetchPointer.id;
971
+ }
972
+ else {
973
+ fetchParamaters["before"] = fetchPointer.id;
974
+ }
975
+ await channel.messages
976
+ .fetch(fetchParamaters)
977
+ .then(async (messagePage) => {
978
+ for (const messageThingy of messagePage) {
979
+ ++messageCount;
980
+ const message = messageThingy[1];
981
+ if (await consumer(message)) {
982
+ earlyExit = true;
983
+ return;
984
+ }
985
+ }
986
+ if (messagePage.size > 0) {
987
+ console.log(`${channel.name}: page: ${page++} | ${messageCount}`);
988
+ }
989
+ fetchPointer = 0 < messagePage.size ? messagePage.at(messagePage.size - 1) : null;
990
+ });
991
+ }
992
+ }
993
+ function offsetDate(date, hourOffset) {
994
+ return new Date(date.getTime() + (0, util_1.hoursToMilliseconds)(hourOffset));
995
+ }
996
+ function newDate(offsetMs = 0) {
997
+ return new Date(Date.now() + offsetMs);
998
+ }
999
+ // export async function forEachChannel(guild: Guild, consumer: (message: Channel) => void | boolean)
1000
+ // {
1001
+ // let nonThreadChannels = (await guild.channels.fetch()).values()
1002
+ // guild.arch
1003
+ // }
1004
+ function dateToDynamicDate(date, format = "F") {
1005
+ return msToDynamicDate(date.getTime(), format);
1006
+ }
1007
+ function msToDynamicDate(ms, format = "F") {
1008
+ return `<t:${Math.floor(ms / 1000)}:${format}>`;
1009
+ }
1010
+ function sToDynamicDate(seconds, format = "F") {
1011
+ return `<t:${Math.floor(seconds)}:${format}>`;
1012
+ }
1013
+ function getCannotAccessString(itemName) {
1014
+ return `Cannot Access ${wrapTitle(itemName)}, ${getRandomPetname()}!`;
1015
+ }
1016
+ function getInvalidString(itemName) {
1017
+ return `Invalid ${wrapTitle(itemName)}, ${getRandomPetname()}!`;
1018
+ }
1019
+ function getMissingString(itemName) {
1020
+ return `Missing ${wrapTitle(itemName)}, ${getRandomPetname()}!`;
1021
+ }
1022
+ function getMissingIdString() {
1023
+ return getMissingString("Id");
1024
+ }
1025
+ function getMissingContentString() {
1026
+ return getMissingString("Content");
1027
+ }
1028
+ function getMissingCommandString() {
1029
+ return getMissingString("Command");
1030
+ }
1031
+ function getMissingSubCommandString() {
1032
+ return getMissingString("Sub Command");
1033
+ }
1034
+ function getMissingSubCommandsCommandString() {
1035
+ return getMissingString("Sub Command's Command");
1036
+ }
1037
+ function getMissingNameString(type = null) {
1038
+ return `Missing${type == null ? "" : ` ${type}`} Name, ${getRandomPetname()}!`;
1039
+ }
1040
+ function getCheckOurDMsString() {
1041
+ return `Please check our DMs, ${getRandomPetname()}!`;
1042
+ }
1043
+ function getIDontKnowThisPersonString() {
1044
+ return `Sorry ${getRandomPetname()}, I don't know this person!`;
1045
+ }
1046
+ function getMessageCannotBeEmptyString() {
1047
+ return `Sorry ${getRandomPetname()}, the message cannot be empty!`;
1048
+ }
1049
+ async function bringRoleToTop(role) {
1050
+ const highestRole = role.guild.roles.highest;
1051
+ if (highestRole) {
1052
+ try {
1053
+ await role.setPosition(highestRole.position - 1);
1054
+ }
1055
+ catch (error) {
1056
+ console.error('Error moving role:', error);
1057
+ return false;
1058
+ }
1059
+ }
1060
+ return false;
1061
+ }
1062
+ async function renameGuildOrChannel(item, name) {
1063
+ await item.setName(name);
1064
+ }
1065
+ async function renameMember(member, name) {
1066
+ await member.setNickname(name);
1067
+ }
1068
+ async function rename(item, name) {
1069
+ if (item instanceof discord_js_1.Guild || item instanceof discord_js_1.TextChannel) {
1070
+ await renameGuildOrChannel(item, name);
1071
+ }
1072
+ if (item instanceof discord_js_1.GuildMember) {
1073
+ await renameMember(item, name);
1074
+ }
1075
+ }
1076
+ // export function removeExcessKeys<T1 extends object, T2 extends keyof T1>(obj: T1): Pick<T1, T2>
1077
+ // {
1078
+ // const result = {} as Pick<T1, T2>
1079
+ // Object.keys(obj).forEach(key =>
1080
+ // {
1081
+ // if (key in obj)
1082
+ // {
1083
+ // result[key as T2] = obj[key as T2]
1084
+ // }
1085
+ // })
1086
+ // return result
1087
+ // }
1088
+ function hasBot(users, bot) {
1089
+ for (const user of users) {
1090
+ if (bot.user == null) {
1091
+ continue;
1092
+ }
1093
+ if (user.id === bot.user.id) {
1094
+ return true;
1095
+ }
1096
+ }
1097
+ return false;
1098
+ }
1099
+ function hasUser(users, checkedUser) {
1100
+ for (const user of users) {
1101
+ if (user.id === checkedUser.id) {
1102
+ return true;
1103
+ }
1104
+ }
1105
+ return false;
1106
+ }
1107
+ function hasUserId(users, userId) {
1108
+ for (const user of users) {
1109
+ if (user.id === userId) {
1110
+ return true;
1111
+ }
1112
+ }
1113
+ return false;
1114
+ }
1115
+ function hasAnyNotBot(users) {
1116
+ for (const user of users) {
1117
+ if (!user.bot) {
1118
+ return true;
1119
+ }
1120
+ }
1121
+ return false;
1122
+ }
1123
+ function hasEmojiByUserId(reaction, userId) {
1124
+ return reaction != null && reaction.users.cache.has(userId);
1125
+ }
1126
+ async function setChannelPrivate(channel, makePrivate, to = channel.guild.roles.everyone) {
1127
+ await channel.permissionOverwrites.create(to, {
1128
+ ViewChannel: !makePrivate
1129
+ });
1130
+ }
1131
+ exports.INVALID_CHANNEL_NAME_CHARS_REGEX = /[^ a-z_\-]/gi;
1132
+ function sanitizeChannelName(name) {
1133
+ return name.replaceAll(exports.INVALID_CHANNEL_NAME_CHARS_REGEX, "").replaceAll(" ", "-").toLowerCase();
1134
+ }
1135
+ function channelMatches(channel, channelType, name) {
1136
+ if (channel.type !== channelType) {
1137
+ return false;
1138
+ }
1139
+ if (channelType !== discord_js_1.ChannelType.GuildCategory) {
1140
+ name = sanitizeChannelName(name);
1141
+ }
1142
+ const channelName = channel["name"];
1143
+ if (channelName == null) {
1144
+ return false;
1145
+ }
1146
+ if (channelName !== name) {
1147
+ return false;
1148
+ }
1149
+ return true;
1150
+ }
1151
+ async function getOrCreateTextChannel(guild, name, parent = null) {
1152
+ for (const channel of parent == null ? guild.channels.cache.values() : parent.children.cache.values()) {
1153
+ if (channelMatches(channel, discord_js_1.ChannelType.GuildText, name)) {
1154
+ return channel;
1155
+ }
1156
+ }
1157
+ return (await guild.channels.create({ name, type: discord_js_1.ChannelType.GuildText, parent }));
1158
+ }
1159
+ async function getOrCreateThreadChannel(channel, name, parent = null) {
1160
+ for (const thread of parent == null ? channel.threads.cache.values() : parent.children.cache.values()) {
1161
+ if (channelMatches(thread, discord_js_1.ChannelType.PublicThread, name)) {
1162
+ return thread;
1163
+ }
1164
+ }
1165
+ return (await channel.threads.create({ name, type: discord_js_1.ChannelType.PublicThread }));
1166
+ }
1167
+ async function getOrCreateCategory(guild, name) {
1168
+ for (const channel of guild.channels.cache.values()) {
1169
+ if (channelMatches(channel, discord_js_1.ChannelType.GuildCategory, name)) {
1170
+ return channel;
1171
+ }
1172
+ }
1173
+ return (await guild.channels.create({ name, type: discord_js_1.ChannelType.GuildCategory }));
1174
+ }
1175
+ async function getCategoryChannels(categoryChannel) {
1176
+ const channels = {};
1177
+ for (const channel of categoryChannel.children.cache.values()) {
1178
+ channels[channel.name] = channel;
1179
+ }
1180
+ return channels;
1181
+ }
1182
+ function discordCrossOut(input) {
1183
+ return `~~${input}~~`;
1184
+ }
1185
+ function discordUnderline(input) {
1186
+ return `__${input}__`;
1187
+ }
1188
+ function discordBold(input, thiccness = 2) {
1189
+ thiccness = (0, util_1.clamp)(thiccness, 1, 3);
1190
+ let asterisks = "";
1191
+ for (let i = 0; i < thiccness; ++i) {
1192
+ asterisks += "*";
1193
+ }
1194
+ return `${asterisks}${input}${asterisks}`;
1195
+ }
1196
+ function dateFromDynamicDate(dynamicDate) {
1197
+ const result = dynamicDate.match(exports.DYNAMIC_DATE_REGEX);
1198
+ if (result == null) {
1199
+ return null;
1200
+ }
1201
+ return new Date(parseInt(result[1]) * 1000);
1202
+ }
1203
+ function referenceToUrl(reference) {
1204
+ if (reference == null) {
1205
+ return "";
1206
+ }
1207
+ return reference.guildId != null ? makeMessageLink(reference.guildId, reference.channelId, reference.messageId) : "";
1208
+ }
1209
+ async function react(message, emoji, timeout = 0) {
1210
+ if (message.interaction != null) {
1211
+ return;
1212
+ }
1213
+ const reaction = await message.react(emoji);
1214
+ if (timeout > 0) {
1215
+ setTimeout(() => {
1216
+ try {
1217
+ reaction.remove();
1218
+ }
1219
+ catch (ignored) { }
1220
+ }, timeout);
1221
+ }
1222
+ }
1223
+ function parseDiscordMessageLinks(input) {
1224
+ const references = [];
1225
+ for (const match of input.matchAll(exports.DISCORD_MESSAGE_LINKS_REGEX)) {
1226
+ references.push({
1227
+ type: discord_js_1.MessageReferenceType.Default,
1228
+ guildId: match[1],
1229
+ channelId: match[2],
1230
+ messageId: match[3],
1231
+ });
1232
+ }
1233
+ return references;
1234
+ }
1235
+ function parseFirstDiscordMessageLink(input) {
1236
+ const match = input.match(exports.DISCORD_MESSAGE_LINK_REGEX);
1237
+ if (match == null) {
1238
+ return null;
1239
+ }
1240
+ return {
1241
+ type: discord_js_1.MessageReferenceType.Default,
1242
+ guildId: match[1],
1243
+ channelId: match[2],
1244
+ messageId: match[3],
1245
+ };
1246
+ }
1247
+ function isChannelPublic(channel) {
1248
+ const everyoneRole = channel.guild.roles.everyone;
1249
+ const permissions = channel.permissionsFor(everyoneRole);
1250
+ return permissions === null || permissions === void 0 ? void 0 : permissions.has(discord_js_1.PermissionsBitField.Flags.ViewChannel);
1251
+ }
1252
+ function messageToReference(message) {
1253
+ return { type: discord_js_1.MessageReferenceType.Default, guildId: message.guildId, channelId: message.channelId, messageId: message.id };
1254
+ }
1255
+ function messageLinkToReference(messageLink) {
1256
+ const result = messageLink.match(exports.DISCORD_MESSAGE_LINK_REGEX);
1257
+ if (result == null) {
1258
+ return null;
1259
+ }
1260
+ return { type: discord_js_1.MessageReferenceType.Default, guildId: result[1], channelId: result[2], messageId: result[3] };
1261
+ }
1262
+ async function getMessageById(channel, messageId) {
1263
+ let message = channel.messages.cache.get(messageId);
1264
+ if (message != null) {
1265
+ return message;
1266
+ }
1267
+ try {
1268
+ return await channel.messages.fetch(messageId);
1269
+ }
1270
+ catch (err) {
1271
+ console.log(err);
1272
+ }
1273
+ }
1274
+ function wrapTitle(text) {
1275
+ return `\`${text}\``;
1276
+ }
1277
+ function isAttachmentSpoiler(attachment) {
1278
+ var _a;
1279
+ return isStringSpoiler((0, path_1.basename)((_a = attachment.url) !== null && _a !== void 0 ? _a : attachment.name));
1280
+ }
1281
+ function isStringSpoiler(text) {
1282
+ return text.startsWith("SPOILER_");
1283
+ }
1284
+ function messageToReplyString(message) {
1285
+ const author = message.author;
1286
+ const content = message.content;
1287
+ let referenceString = `${sanitizeDiscordMessage(`${message.url}\n> By: ${getUserName(message.author)} | At ${dateToDynamicDate(message.createdAt)}`)}\n`;
1288
+ if (content.length > 0) {
1289
+ referenceString += `> ${content.slice(0, exports.REPLY_REFERENCE_MAX_LENGTH)}`;
1290
+ if (content.length > exports.REPLY_REFERENCE_MAX_LENGTH) {
1291
+ referenceString += `...`;
1292
+ }
1293
+ referenceString += `\n`;
1294
+ }
1295
+ for (const embed of message.embeds) {
1296
+ if (embed.title && embed.title.trim().length > 0) {
1297
+ referenceString += `> ${embed.title}\n`;
1298
+ }
1299
+ if (embed.description && embed.description.trim().length > 0) {
1300
+ referenceString += `> ${embed.description}\n`;
1301
+ }
1302
+ }
1303
+ for (const attachment of attachmentsToFiles(message.attachments)) {
1304
+ referenceString += `> ${attachment}\n`;
1305
+ }
1306
+ return referenceString;
1307
+ }
1308
+ function timeAndUserIdToEmbedBuilder(timeMs, userId, content) {
1309
+ return makeEmbed(`${msToDynamicDate(timeMs)}`, `<@${userId}>${content == null ? "" : `\n${content}`}`);
1310
+ }
1311
+ function filterUselessMetadata(url) {
1312
+ return url.replaceAll(exports.USELESS_LINK_METADATA_REGEX, "");
1313
+ }
1314
+ function isTextChannel(channel) {
1315
+ return channel["send"] != null;
1316
+ }
1317
+ function embedToString(embed) {
1318
+ return `${embed.title == null ? "" : `Title: ${embed.title}\n`}${embed.description == null ? "" : `Description: ${embed.description}\n`}`;
1319
+ }
1320
+ async function getAllChannels(guild) {
1321
+ const channels = new Set(guild.channels.cache.values());
1322
+ for (const channel of (await guild.channels.fetch()).values()) {
1323
+ if (channel == null) {
1324
+ continue;
1325
+ }
1326
+ channels.add(channel);
1327
+ }
1328
+ return channels;
1329
+ }
1330
+ function arrayToDisplayUpToString(items, mapper, maxDisplayCount = 5) {
1331
+ return `[${items.slice(0, maxDisplayCount).map(mapper).join(", ")}${items.length > maxDisplayCount ? ` and ${wrapTitle(items.length - maxDisplayCount)} more....` : ""}]`;
1332
+ }
1333
+ function debugLog(input) {
1334
+ console.log(util_1.chalk.bgMagentaBright(`[DEBUG]${input}`));
1335
+ }
1336
+ async function backupToGit() {
1337
+ console.log(`~~~Backing Up~~~`);
1338
+ const result = await (0, util_1.runCommandRejectAsResolve)(`./git_commit && git pull && ./git_push`, `starlight`);
1339
+ console.log(`Backup Result: ${result}`);
1340
+ return result;
1341
+ }
1342
+ async function getOrCreateRole(roleManager, data) {
1343
+ let role;
1344
+ if (data.id != null) {
1345
+ role = roleManager.cache.get(data.id);
1346
+ }
1347
+ if (role == null) {
1348
+ role = roleManager.cache.find(role => role.name == data.name);
1349
+ if (role == null) {
1350
+ return await roleManager.create(data);
1351
+ }
1352
+ }
1353
+ return role;
1354
+ }
1355
+ async function getRoleById(roleManager, roleId) {
1356
+ return roleManager.cache.get(roleId);
1357
+ }
1358
+ function tooLongForDiscord(input) {
1359
+ const length = (0, util_1.decide)(() => {
1360
+ if ((0, mathjs_1.isArray)(input)) {
1361
+ return (0, mathjs_1.sum)(input.map(item => item.length));
1362
+ }
1363
+ if ((0, util_1.isString)(input)) {
1364
+ return input.length;
1365
+ }
1366
+ return input;
1367
+ });
1368
+ return length > fields_1.DISCORD_MESSAGE_LENGTH_LIMIT;
1369
+ }
1370
+ //# sourceMappingURL=discord-util.js.map