@mephisto5558/command 0.7.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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/dist/classes/command/index.d.ts +99 -0
  4. package/dist/classes/command/index.d.ts.map +1 -0
  5. package/dist/classes/command/index.js +378 -0
  6. package/dist/classes/command/index.js.map +1 -0
  7. package/dist/classes/command/utils.d.ts +29 -0
  8. package/dist/classes/command/utils.d.ts.map +1 -0
  9. package/dist/classes/command/utils.js +2 -0
  10. package/dist/classes/command/utils.js.map +1 -0
  11. package/dist/classes/commandManager/index.d.ts +43 -0
  12. package/dist/classes/commandManager/index.d.ts.map +1 -0
  13. package/dist/classes/commandManager/index.js +186 -0
  14. package/dist/classes/commandManager/index.js.map +1 -0
  15. package/dist/classes/commandOption/index.d.ts +124 -0
  16. package/dist/classes/commandOption/index.d.ts.map +1 -0
  17. package/dist/classes/commandOption/index.js +378 -0
  18. package/dist/classes/commandOption/index.js.map +1 -0
  19. package/dist/classes/commandOption/utils.d.ts +145 -0
  20. package/dist/classes/commandOption/utils.d.ts.map +1 -0
  21. package/dist/classes/commandOption/utils.js +3 -0
  22. package/dist/classes/commandOption/utils.js.map +1 -0
  23. package/dist/classes/utils.d.ts +42 -0
  24. package/dist/classes/utils.d.ts.map +1 -0
  25. package/dist/classes/utils.js +81 -0
  26. package/dist/classes/utils.js.map +1 -0
  27. package/dist/db.d.ts +22 -0
  28. package/dist/db.d.ts.map +1 -0
  29. package/dist/db.js +2 -0
  30. package/dist/db.js.map +1 -0
  31. package/dist/discord.js.d.ts +172 -0
  32. package/dist/discord.js.d.ts.map +1 -0
  33. package/dist/discord.js.js +2 -0
  34. package/dist/discord.js.js.map +1 -0
  35. package/dist/index.d.ts +71 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +22 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/tsconfig.tsbuildinfo +1 -0
  40. package/dist/utils/CooldownsManager.d.ts +8 -0
  41. package/dist/utils/CooldownsManager.d.ts.map +1 -0
  42. package/dist/utils/CooldownsManager.js +39 -0
  43. package/dist/utils/CooldownsManager.js.map +1 -0
  44. package/dist/utils/capitalize.d.ts +2 -0
  45. package/dist/utils/capitalize.d.ts.map +1 -0
  46. package/dist/utils/capitalize.js +4 -0
  47. package/dist/utils/capitalize.js.map +1 -0
  48. package/dist/utils/constants.d.ts +2 -0
  49. package/dist/utils/constants.d.ts.map +1 -0
  50. package/dist/utils/constants.js +2 -0
  51. package/dist/utils/constants.js.map +1 -0
  52. package/dist/utils/getCommands.d.ts +18 -0
  53. package/dist/utils/getCommands.d.ts.map +1 -0
  54. package/dist/utils/getCommands.js +36 -0
  55. package/dist/utils/getCommands.js.map +1 -0
  56. package/dist/utils/getDirectories.d.ts +2 -0
  57. package/dist/utils/getDirectories.d.ts.map +1 -0
  58. package/dist/utils/getDirectories.js +5 -0
  59. package/dist/utils/getDirectories.js.map +1 -0
  60. package/dist/utils/getFilename.d.ts +5 -0
  61. package/dist/utils/getFilename.d.ts.map +1 -0
  62. package/dist/utils/getFilename.js +5 -0
  63. package/dist/utils/getFilename.js.map +1 -0
  64. package/dist/utils/index.d.ts +9 -0
  65. package/dist/utils/index.d.ts.map +1 -0
  66. package/dist/utils/index.js +9 -0
  67. package/dist/utils/index.js.map +1 -0
  68. package/dist/utils/isSnowflake.d.ts +2 -0
  69. package/dist/utils/isSnowflake.d.ts.map +1 -0
  70. package/dist/utils/isSnowflake.js +4 -0
  71. package/dist/utils/isSnowflake.js.map +1 -0
  72. package/dist/utils/loadFile.d.ts +2 -0
  73. package/dist/utils/loadFile.d.ts.map +1 -0
  74. package/dist/utils/loadFile.js +32 -0
  75. package/dist/utils/loadFile.js.map +1 -0
  76. package/package.json +58 -0
  77. package/translationSchema.jsonc +114 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CooldownsManager.d.ts","sourceRoot":"","sources":["../../src/utils/CooldownsManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,IAAI,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElG,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,KAAK,2DAAgE;IAGrE,MAAM,CACJ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EACzC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,GACnE,MAAM;CA2CV"}
@@ -0,0 +1,39 @@
1
+ import { isMessage } from "../classes/utils.js";
2
+ import { CooldownType } from "../index.js";
3
+ export default class CooldownsManager {
4
+ cache = new Map();
5
+ update(name, context, cooldowns) {
6
+ const createdAt = context.createdAt.getTime(), timeStamps = this.cache.get(name) ?? this.cache.set(name, new Map()).get(name), currentCooldowns = [];
7
+ for (const [cdName, value] of Object.entries(cooldowns)) {
8
+ if (!value)
9
+ continue;
10
+ let areaId;
11
+ switch (cdName) {
12
+ case CooldownType.User:
13
+ areaId = isMessage(context) ? context.author.id : context.user.id;
14
+ break;
15
+ case CooldownType.Guild:
16
+ areaId = context.guildId ?? undefined;
17
+ break;
18
+ case CooldownType.Channel:
19
+ areaId = context.channelId;
20
+ break;
21
+ }
22
+ if (!areaId)
23
+ continue;
24
+ const typeCache = timeStamps.get(cdName) ?? timeStamps.set(cdName, new Map()).get(cdName), timestamp = typeCache.get(areaId) ?? 0;
25
+ if (timestamp > createdAt)
26
+ currentCooldowns.push(timestamp - createdAt);
27
+ else {
28
+ typeCache.set(areaId, createdAt + value);
29
+ setTimeout(() => {
30
+ typeCache.delete(areaId);
31
+ if (!typeCache.size)
32
+ timeStamps.delete(cdName);
33
+ }, value);
34
+ }
35
+ }
36
+ return Math.max(0, ...currentCooldowns);
37
+ }
38
+ }
39
+ //# sourceMappingURL=CooldownsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CooldownsManager.js","sourceRoot":"","sources":["../../src/utils/CooldownsManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,KAAK,GAAG,IAAI,GAAG,EAAqD,CAAC;IAGrE,MAAM,CACJ,IAAY,EAAE,OAA2B,EACzC,SAAoE;QAEpE,MACE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,EAEvC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAE,EAC/E,gBAAgB,GAAG,EAAE,CAAC;QAExB,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACxD,IAAI,CAAC,KAAK;gBAAE,SAAS;YAErB,IAAI,MAA6B,CAAC;YAClC,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,YAAY,CAAC,IAAI;oBACpB,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;oBAClE,MAAM;gBACR,KAAK,YAAY,CAAC,KAAK;oBACrB,MAAM,GAAG,OAAO,CAAC,OAAO,IAAI,SAAS,CAAC;oBACtC,MAAM;gBACR,KAAK,YAAY,CAAC,OAAO;oBACvB,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;oBAC3B,MAAM;YACV,CAAC;YAED,IAAI,CAAC,MAAM;gBAAE,SAAS;YAEtB,MAEE,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAE,EACpF,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAEzC,IAAI,SAAS,GAAG,SAAS;gBAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;iBACnE,CAAC;gBACJ,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC,CAAC;gBAEzC,UAAU,CAAC,GAAG,EAAE;oBACd,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACzB,IAAI,CAAC,SAAS,CAAC,IAAI;wBAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACjD,CAAC,EAAE,KAAK,CAAC,CAAC;YACZ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export default function capitalize<T extends string>(str: T): Capitalize<T>;
2
+ //# sourceMappingURL=capitalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.d.ts","sourceRoot":"","sources":["../../src/utils/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAE1E"}
@@ -0,0 +1,4 @@
1
+ export default function capitalize(str) {
2
+ return str.charAt(0).toUpperCase() + str.slice(1);
3
+ }
4
+ //# sourceMappingURL=capitalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/utils/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAmB,GAAM;IACzD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAkB,CAAC;AACrE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const autocompleteOptionsMaxAmt = 25, choiceValueMaxLength = 100, choiceValueMinLength = 2, choicesMaxAmt = 25, descriptionMaxLength = 100;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MACL,yBAAyB,KAAK,EAC9B,oBAAoB,MAAM,EAC1B,oBAAoB,IAAI,EACxB,aAAa,KAAK,EAClB,oBAAoB,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const autocompleteOptionsMaxAmt = 25, choiceValueMaxLength = 100, choiceValueMinLength = 2, choicesMaxAmt = 25, descriptionMaxLength = 100;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MACL,yBAAyB,GAAG,EAAE,EAC9B,oBAAoB,GAAG,GAAG,EAC1B,oBAAoB,GAAG,CAAC,EACxB,aAAa,GAAG,EAAE,EAClB,oBAAoB,GAAG,GAAG,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type * as Discord from 'discord.js';
2
+ import type { Locale, Translator } from '@mephisto5558/i18n';
3
+ import type { CommandInitialized as Command, CommandManager } from '../index.ts';
4
+ type category = {
5
+ category: string;
6
+ subTitle: '';
7
+ aliasesDisabled: boolean;
8
+ list: command[];
9
+ };
10
+ type command = {
11
+ commandName: string;
12
+ commandUsage: string;
13
+ commandDescription: string;
14
+ commandAlias: string;
15
+ };
16
+ export default function getCommands(this: Discord.Client, lang: Translator<true, Locale>, commands: CommandManager['commands'], excludeCategories?: Command['category'][]): category[];
17
+ export {};
18
+ //# sourceMappingURL=getCommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCommands.d.ts","sourceRoot":"","sources":["../../src/utils/getCommands.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,OAAO,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,IAAI,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjF,KAAK,QAAQ,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC;AAC9F,KAAK,OAAO,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/G,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,IAAI,EAAE,OAAO,CAAC,MAAM,EACpB,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,EAC9B,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,EACpC,iBAAiB,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,GACxC,QAAQ,EAAE,CAwCZ"}
@@ -0,0 +1,36 @@
1
+ import { CommandType } from "../classes/utils.js";
2
+ import capitalize from "./capitalize.js";
3
+ export default function getCommands(lang, commands, excludeCategories) {
4
+ const commandList = commands.reduce((acc, { command }) => {
5
+ if (excludeCategories?.includes(command.category) || command.disabled)
6
+ return acc;
7
+ let category = acc.find(e => e.category == command.category);
8
+ if (!category) {
9
+ category = {
10
+ category: command.category,
11
+ subTitle: '',
12
+ aliasesDisabled: false,
13
+ list: []
14
+ };
15
+ acc.push(category);
16
+ }
17
+ category.list.push({
18
+ commandName: command.name,
19
+ commandUsage: ((command.types.includes(CommandType.Slash) ? lang('others.getCommands.lookAtOptionDesc') ?? '' : '')
20
+ + (lang(`${command.id}.usage.usage`)?.replaceAll(new RegExp(`${CommandType.Slash} command:`, 'gi'), '') ?? '')
21
+ || (lang('others.getCommands.noInfo') ?? '')).trim().replaceAll('\n', '<br>&nbsp'),
22
+ commandDescription: command.descriptionLocalizations[lang.config.locale ?? lang.defaultConfig.defaultLocale] ?? command.description,
23
+ commandAlias: ((command.aliases[CommandType.Prefix].length ? `${capitalize(CommandType.Prefix)}: ${command.aliases[CommandType.Prefix].join(', ')}\n` : '')
24
+ + (command.aliases[CommandType.Slash].length ? `${capitalize(CommandType.Slash)}: ${command.aliases[CommandType.Slash].join(', ')}` : '')
25
+ || (lang('global.none') ?? '')).trim().replaceAll('\n', '<br>&nbsp')
26
+ });
27
+ return acc;
28
+ }, []);
29
+ commandList.sort((a, b) => a.category == 'others' ? 1 : b.list.length - a.list.length);
30
+ return commandList.map(e => {
31
+ e.category = lang(`commands.${e.category}.categoryName`) ?? '';
32
+ e.aliasesDisabled = !e.list.some(e => e.commandAlias != lang('global.none'));
33
+ return e;
34
+ });
35
+ }
36
+ //# sourceMappingURL=getCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCommands.js","sourceRoot":"","sources":["../../src/utils/getCommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,UAAU,MAAM,iBAAiB,CAAC;AASzC,MAAM,CAAC,OAAO,UAAU,WAAW,CAEjC,IAA8B,EAC9B,QAAoC,EACpC,iBAAyC;IAEzC,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAa,CAAC,GAAG,EAAE,EAAE,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AAC,CAAC,CAAC;QAC7E,OAAO,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function getDirectories(path: string): Promise<string[]>;
2
+ //# sourceMappingURL=getDirectories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDirectories.d.ts","sourceRoot":"","sources":["../../src/utils/getDirectories.ts"],"names":[],"mappings":"AAEA,wBAA8B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE5E"}
@@ -0,0 +1,5 @@
1
+ import { readdir } from 'node:fs/promises';
2
+ export default async function getDirectories(path) {
3
+ return (await readdir(path, { withFileTypes: true })).reduce((acc, e) => e.isDirectory() ? [...acc, e.name] : acc, []);
4
+ }
5
+ //# sourceMappingURL=getDirectories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDirectories.js","sourceRoot":"","sources":["../../src/utils/getDirectories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY;IACvD,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAW,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACnI,CAAC"}
@@ -0,0 +1,5 @@
1
+ export default function getFilename<T extends string>(path: T): IfExtendsStrict<T, Lowercase<string>, {
2
+ ifTrue: Lowercase<string>;
3
+ ifFalse: string;
4
+ }>;
5
+ //# sourceMappingURL=getFilename.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilename.d.ts","sourceRoot":"","sources":["../../src/utils/getFilename.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,CAAC,SAAS,MAAM,EAChB,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE;IAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhG"}
@@ -0,0 +1,5 @@
1
+ import { basename, extname } from 'node:path';
2
+ export default function getFilename(path) {
3
+ return basename(path, extname(path));
4
+ }
5
+ //# sourceMappingURL=getFilename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFilename.js","sourceRoot":"","sources":["../../src/utils/getFilename.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,WAAW,CAEjC,IAAO;IACP,OAAO,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAsC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { default as capitalize } from './capitalize.ts';
2
+ export * as constants from './constants.ts';
3
+ export { default as CooldownsManager } from './CooldownsManager.ts';
4
+ export { default as getCommands } from './getCommands.ts';
5
+ export { default as getDirectories } from './getDirectories.ts';
6
+ export { default as getFilename } from './getFilename.ts';
7
+ export { default as isSnowflake } from './isSnowflake.ts';
8
+ export { default as loadFile } from './loadFile.ts';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { default as capitalize } from "./capitalize.js";
2
+ export * as constants from "./constants.js";
3
+ export { default as CooldownsManager } from "./CooldownsManager.js";
4
+ export { default as getCommands } from "./getCommands.js";
5
+ export { default as getDirectories } from "./getDirectories.js";
6
+ export { default as getFilename } from "./getFilename.js";
7
+ export { default as isSnowflake } from "./isSnowflake.js";
8
+ export { default as loadFile } from "./loadFile.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function isSnowflake(str: string & {} | Snowflake): str is Snowflake;
2
+ //# sourceMappingURL=isSnowflake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSnowflake.d.ts","sourceRoot":"","sources":["../../src/utils/isSnowflake.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,GAAG,SAAS,GAAG,GAAG,IAAI,SAAS,CAElF"}
@@ -0,0 +1,4 @@
1
+ export default function isSnowflake(str) {
2
+ return /^\d*$/.test(str);
3
+ }
4
+ //# sourceMappingURL=isSnowflake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSnowflake.js","sourceRoot":"","sources":["../../src/utils/isSnowflake.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,GAA4B;IAC9D,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export default function loadFile(path: string): Promise<unknown>;
2
+ //# sourceMappingURL=loadFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadFile.d.ts","sourceRoot":"","sources":["../../src/utils/loadFile.ts"],"names":[],"mappings":"AAMA,wBAA8B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBrE"}
@@ -0,0 +1,32 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ import { createRequire } from 'node:module';
10
+ import { pathToFileURL } from 'node:url';
11
+ import { init, isSupported } from 'import-without-cache';
12
+ export default async function loadFile(path) {
13
+ try {
14
+ const require = createRequire(import.meta.url), resolvedPath = require.resolve(path);
15
+ delete require.cache[resolvedPath];
16
+ return require(resolvedPath);
17
+ }
18
+ catch (err) {
19
+ if (!(err instanceof Error && 'code' in err) || err.code !== 'ERR_REQUIRE_ESM')
20
+ throw err;
21
+ if (!isSupported)
22
+ return import(__rewriteRelativeImportExtension(pathToFileURL(`${path}?t=${Date.now()}`).href));
23
+ const deregister = init();
24
+ try {
25
+ return await import(__rewriteRelativeImportExtension(pathToFileURL(path).href), { with: { cache: 'no' } });
26
+ }
27
+ finally {
28
+ deregister();
29
+ }
30
+ }
31
+ }
32
+ //# sourceMappingURL=loadFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadFile.js","sourceRoot":"","sources":["../../src/utils/loadFile.ts"],"names":[],"mappings":";;;;;;;;AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACjD,IAAI,CAAC;QACH,MACE,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EACxC,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAGvC,OAAO,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACnC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,iBAAiB;YAAE,MAAM,GAAG,CAAC;QAG1F,IAAI,CAAC,WAAW;YAAE,OAAO,MAAM,kCAAC,aAAa,CAAC,GAAG,IAAI,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAC,CAAC;QAE/E,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;QAE1B,IAAI,CAAC;YAAC,OAAO,MAAM,MAAM,kCAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,GAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAAC,CAAC;gBACzE,CAAC;YAAC,UAAU,EAAE,CAAC;QAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@mephisto5558/command",
3
+ "version": "0.7.0",
4
+ "description": "Discord.js command class and registering logic for slash- and prefix commands",
5
+ "keywords": [
6
+ "command",
7
+ "discord",
8
+ "discord.js"
9
+ ],
10
+ "homepage": "https://github.com/Mephisto5558/Command_v2#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/Mephisto5558/Command_v2/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/Mephisto5558/Command_v2.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Mephisto5558",
20
+ "type": "module",
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "!**/*.tsbuildinfo",
25
+ "*Schema.jsonc",
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "npm run clean && tsc -p ./tsconfig.build.json",
30
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true });\"",
31
+ "lint": "eslint . --cache --cache-location ./node_modules/.cache/eslint/ >eslint.log",
32
+ "test": "echo \"Error: no test specified\"",
33
+ "watch": "npm run build -- --watch"
34
+ },
35
+ "dependencies": {
36
+ "import-without-cache": "0.4.x",
37
+ "type-better-ms": "0.2.x"
38
+ },
39
+ "devDependencies": {
40
+ "@mephisto5558/eslint-config": "latest",
41
+ "@mephisto5558/i18n": "2.x",
42
+ "discord.js": "14.x"
43
+ },
44
+ "peerDependencies": {
45
+ "@mephisto5558/i18n": "2.x",
46
+ "discord.js": "14.x"
47
+ },
48
+ "engines": {
49
+ "node": ">=22.18.0"
50
+ },
51
+ "devEngines": {
52
+ "runtime": {
53
+ "name": "node",
54
+ "onFail": "error",
55
+ "version": ">=22.18.0"
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://example.com/language-file.schema.json",
4
+ "title": "LanguageFileSchema",
5
+ "type": "object",
6
+ "required": ["$schema", "categoryName", "categoryDescription"],
7
+ "properties": {
8
+ "$schema": { "type": "string" },
9
+ "categoryName": { "type": "string" },
10
+ "categoryDescription": { "type": "string" }
11
+ },
12
+ "patternProperties": {
13
+ "^[\\p{Ll}0-9_-]+$": {
14
+ "type": "object",
15
+ "required": ["description"],
16
+ "properties": {
17
+ "description": {
18
+ "type": "string",
19
+ "maxLength": 100
20
+ },
21
+ "usage": {
22
+ "type": "object",
23
+ "required": ["usage"],
24
+ "properties": {
25
+ "usage": { "type": "string" },
26
+ "examples": { "type": "string" }
27
+ },
28
+ "additionalProperties": false
29
+ },
30
+ "options": {
31
+ "type": "object",
32
+ "patternProperties": {
33
+ "^[\\p{Ll}0-9_-]+$": { "$ref": "#/$defs/optionLevel1" }
34
+ },
35
+ "additionalProperties": false
36
+ }
37
+ },
38
+ "patternProperties": {
39
+ "^(?!\\$schema$|categoryName$|categoryDescription$|description$|usage$|options$)[a-zA-Z0-9_-]+$": {
40
+ "$ref": "#/$defs/deepRecord"
41
+ }
42
+ },
43
+ "additionalProperties": false
44
+ }
45
+ },
46
+ "additionalProperties": false,
47
+
48
+ "$defs": {
49
+ "deepRecord": {
50
+ "anyOf": [
51
+ { "type": "string" },
52
+ { "type": "array", "items": { "type": "string" } },
53
+ {
54
+ "type": "object",
55
+ "additionalProperties": { "$ref": "#/$defs/deepRecord" }
56
+ }
57
+ ]
58
+ },
59
+ "choiceDefinition": {
60
+ "type": "object",
61
+ "additionalProperties": {
62
+ "type": "string",
63
+ "maxLength": 32
64
+ }
65
+ },
66
+ "optionBase": {
67
+ "type": "object",
68
+ "required": ["description"],
69
+ "properties": {
70
+ "description": {
71
+ "type": "string",
72
+ "maxLength": 100
73
+ },
74
+ "choices": { "$ref": "#/$defs/choiceDefinition" }
75
+ },
76
+ "allOf": [
77
+ {
78
+ "not": {
79
+ "required": ["options", "choices"]
80
+ }
81
+ }
82
+ ]
83
+ },
84
+ "optionLevel1": {
85
+ "allOf": [{ "$ref": "#/$defs/optionBase" }],
86
+ "properties": {
87
+ "options": {
88
+ "type": "object",
89
+ "patternProperties": {
90
+ "^[\\p{Ll}0-9_-]+$": { "$ref": "#/$defs/optionLevel2" }
91
+ },
92
+ "additionalProperties": false
93
+ }
94
+ }
95
+ },
96
+ "optionLevel2": {
97
+ "allOf": [{ "$ref": "#/$defs/optionBase" }],
98
+ "properties": {
99
+ "options": {
100
+ "type": "object",
101
+ "patternProperties": {
102
+ "^[\\p{Ll}0-9_-]+$": { "$ref": "#/$defs/optionLevel3" }
103
+ },
104
+ "additionalProperties": false
105
+ }
106
+ }
107
+ },
108
+ "optionLevel3": {
109
+ "allOf": [{ "$ref": "#/$defs/optionBase" }],
110
+ "properties": {},
111
+ "not": { "required": ["options"] }
112
+ }
113
+ }
114
+ }