xernerx 4.14.0 → 4.15.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 (140) hide show
  1. package/dist/cjs/build/XernerxContextCommand.js +124 -0
  2. package/dist/cjs/build/XernerxEvent.js +34 -0
  3. package/dist/cjs/build/XernerxInhibitor.js +30 -0
  4. package/dist/cjs/build/XernerxMessageCommand.js +122 -0
  5. package/dist/cjs/build/XernerxSlashCommand.js +180 -0
  6. package/dist/cjs/client/XernerxClient.js +105 -0
  7. package/dist/cjs/client/XernerxShardClient.js +56 -0
  8. package/dist/cjs/functions/deploy.js +66 -0
  9. package/dist/cjs/functions/load.js +38 -0
  10. package/dist/cjs/functions/reload.js +33 -0
  11. package/dist/cjs/functions/setPresence.js +24 -0
  12. package/dist/cjs/functions/xernerxUser.js +15 -0
  13. package/dist/cjs/handlers/CommandHandler.js +342 -0
  14. package/dist/cjs/handlers/EventHandler.js +32 -0
  15. package/dist/cjs/handlers/ExtensionHandler.js +32 -0
  16. package/dist/cjs/handlers/Handler.js +48 -0
  17. package/dist/cjs/handlers/InhibitorHandler.js +34 -0
  18. package/dist/cjs/handlers/IntegrationHandler.js +29 -0
  19. package/dist/cjs/main.js +36 -0
  20. package/dist/cjs/models/Arguments.js +159 -0
  21. package/dist/cjs/models/Cooldowns.js +36 -0
  22. package/dist/cjs/tools/XernerxError.js +14 -0
  23. package/dist/cjs/tools/XernerxIntents.js +27 -0
  24. package/dist/cjs/tools/XernerxLog.js +98 -0
  25. package/dist/cjs/tools/XernerxText.js +92 -0
  26. package/dist/cjs/types/extenders.js +3 -0
  27. package/dist/cjs/types/interfaces.js +3 -0
  28. package/dist/cjs/types/types.js +3 -0
  29. package/dist/{utils → cjs/utils}/ClientUtil.d.ts +2 -1
  30. package/dist/cjs/utils/ClientUtil.js +84 -0
  31. package/dist/{utils → cjs/utils}/InteractionUtil.d.ts +3 -2
  32. package/dist/cjs/utils/InteractionUtil.js +156 -0
  33. package/dist/{utils → cjs/utils}/MessageUtil.d.ts +3 -0
  34. package/dist/cjs/utils/MessageUtil.js +170 -0
  35. package/dist/cjs/utils/Util.js +14 -0
  36. package/dist/cjs/validators/commandValidation.js +127 -0
  37. package/dist/{validators → cjs/validators}/inhibitorValidations.d.ts +1 -1
  38. package/dist/cjs/validators/inhibitorValidations.js +49 -0
  39. package/dist/mjs/build/XernerxContextCommand.d.ts +53 -0
  40. package/dist/mjs/build/XernerxEvent.d.ts +25 -0
  41. package/dist/mjs/build/XernerxInhibitor.d.ts +29 -0
  42. package/dist/mjs/build/XernerxMessageCommand.d.ts +57 -0
  43. package/dist/mjs/build/XernerxSlashCommand.d.ts +69 -0
  44. package/dist/mjs/client/XernerxClient.d.ts +53 -0
  45. package/dist/mjs/client/XernerxShardClient.d.ts +21 -0
  46. package/dist/mjs/functions/deploy.d.ts +3 -0
  47. package/dist/mjs/functions/load.d.ts +4 -0
  48. package/dist/mjs/functions/reload.d.ts +3 -0
  49. package/dist/mjs/functions/setPresence.d.ts +4 -0
  50. package/dist/mjs/functions/xernerxUser.d.ts +4 -0
  51. package/dist/mjs/handlers/CommandHandler.d.ts +16 -0
  52. package/dist/{handlers → mjs/handlers}/CommandHandler.js +1 -1
  53. package/dist/mjs/handlers/EventHandler.d.ts +9 -0
  54. package/dist/mjs/handlers/ExtensionHandler.d.ts +9 -0
  55. package/dist/mjs/handlers/Handler.d.ts +14 -0
  56. package/dist/mjs/handlers/InhibitorHandler.d.ts +9 -0
  57. package/dist/{handlers/WebhookHandler.d.ts → mjs/handlers/IntegrationHandler.d.ts} +8 -1
  58. package/dist/mjs/main.d.ts +40 -0
  59. package/dist/mjs/models/Arguments.d.ts +9 -0
  60. package/dist/mjs/models/Cooldowns.d.ts +11 -0
  61. package/dist/mjs/tools/XernerxError.d.ts +7 -0
  62. package/dist/mjs/tools/XernerxIntents.d.ts +5 -0
  63. package/dist/mjs/tools/XernerxLog.d.ts +28 -0
  64. package/dist/mjs/tools/XernerxText.d.ts +30 -0
  65. package/dist/mjs/types/extenders.d.ts +61 -0
  66. package/dist/mjs/types/interfaces.d.ts +256 -0
  67. package/dist/mjs/types/types.d.ts +14 -0
  68. package/dist/mjs/utils/ClientUtil.d.ts +19 -0
  69. package/dist/{utils → mjs/utils}/ClientUtil.js +3 -0
  70. package/dist/mjs/utils/InteractionUtil.d.ts +25 -0
  71. package/dist/{utils → mjs/utils}/InteractionUtil.js +33 -3
  72. package/dist/mjs/utils/MessageUtil.d.ts +26 -0
  73. package/dist/{utils → mjs/utils}/MessageUtil.js +29 -0
  74. package/dist/mjs/utils/Util.d.ts +9 -0
  75. package/dist/mjs/validators/commandValidation.d.ts +7 -0
  76. package/dist/{validators → mjs/validators}/commandValidation.js +10 -22
  77. package/dist/mjs/validators/inhibitorValidations.d.ts +9 -0
  78. package/package.json +7 -4
  79. package/dist/functions/sendWebhook.d.ts +0 -4
  80. package/dist/functions/sendWebhook.js +0 -14
  81. package/dist/handlers/WebhookHandler.js +0 -10
  82. package/dist/{build → cjs/build}/XernerxContextCommand.d.ts +0 -0
  83. package/dist/{build → cjs/build}/XernerxEvent.d.ts +0 -0
  84. package/dist/{build → cjs/build}/XernerxInhibitor.d.ts +0 -0
  85. package/dist/{build → cjs/build}/XernerxMessageCommand.d.ts +0 -0
  86. package/dist/{build → cjs/build}/XernerxSlashCommand.d.ts +0 -0
  87. package/dist/{client → cjs/client}/XernerxClient.d.ts +3 -3
  88. /package/dist/{client → cjs/client}/XernerxShardClient.d.ts +0 -0
  89. /package/dist/{functions → cjs/functions}/deploy.d.ts +0 -0
  90. /package/dist/{functions → cjs/functions}/load.d.ts +0 -0
  91. /package/dist/{functions → cjs/functions}/reload.d.ts +0 -0
  92. /package/dist/{functions → cjs/functions}/setPresence.d.ts +0 -0
  93. /package/dist/{functions → cjs/functions}/xernerxUser.d.ts +0 -0
  94. /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
  95. /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
  96. /package/dist/{handlers → cjs/handlers}/ExtensionHandler.d.ts +0 -0
  97. /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
  98. /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
  99. /package/dist/{handlers → cjs/handlers}/IntegrationHandler.d.ts +0 -0
  100. /package/dist/{main.d.ts → cjs/main.d.ts} +0 -0
  101. /package/dist/{models → cjs/models}/Arguments.d.ts +0 -0
  102. /package/dist/{models → cjs/models}/Cooldowns.d.ts +0 -0
  103. /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
  104. /package/dist/{tools → cjs/tools}/XernerxIntents.d.ts +0 -0
  105. /package/dist/{tools → cjs/tools}/XernerxLog.d.ts +0 -0
  106. /package/dist/{tools → cjs/tools}/XernerxText.d.ts +0 -0
  107. /package/dist/{types → cjs/types}/extenders.d.ts +0 -0
  108. /package/dist/{types → cjs/types}/interfaces.d.ts +0 -0
  109. /package/dist/{types → cjs/types}/types.d.ts +0 -0
  110. /package/dist/{utils → cjs/utils}/Util.d.ts +0 -0
  111. /package/dist/{validators → cjs/validators}/commandValidation.d.ts +0 -0
  112. /package/dist/{build → mjs/build}/XernerxContextCommand.js +0 -0
  113. /package/dist/{build → mjs/build}/XernerxEvent.js +0 -0
  114. /package/dist/{build → mjs/build}/XernerxInhibitor.js +0 -0
  115. /package/dist/{build → mjs/build}/XernerxMessageCommand.js +0 -0
  116. /package/dist/{build → mjs/build}/XernerxSlashCommand.js +0 -0
  117. /package/dist/{client → mjs/client}/XernerxClient.js +0 -0
  118. /package/dist/{client → mjs/client}/XernerxShardClient.js +0 -0
  119. /package/dist/{functions → mjs/functions}/deploy.js +0 -0
  120. /package/dist/{functions → mjs/functions}/load.js +0 -0
  121. /package/dist/{functions → mjs/functions}/reload.js +0 -0
  122. /package/dist/{functions → mjs/functions}/setPresence.js +0 -0
  123. /package/dist/{functions → mjs/functions}/xernerxUser.js +0 -0
  124. /package/dist/{handlers → mjs/handlers}/EventHandler.js +0 -0
  125. /package/dist/{handlers → mjs/handlers}/ExtensionHandler.js +0 -0
  126. /package/dist/{handlers → mjs/handlers}/Handler.js +0 -0
  127. /package/dist/{handlers → mjs/handlers}/InhibitorHandler.js +0 -0
  128. /package/dist/{handlers → mjs/handlers}/IntegrationHandler.js +0 -0
  129. /package/dist/{main.js → mjs/main.js} +0 -0
  130. /package/dist/{models → mjs/models}/Arguments.js +0 -0
  131. /package/dist/{models → mjs/models}/Cooldowns.js +0 -0
  132. /package/dist/{tools → mjs/tools}/XernerxError.js +0 -0
  133. /package/dist/{tools → mjs/tools}/XernerxIntents.js +0 -0
  134. /package/dist/{tools → mjs/tools}/XernerxLog.js +0 -0
  135. /package/dist/{tools → mjs/tools}/XernerxText.js +0 -0
  136. /package/dist/{types → mjs/types}/extenders.js +0 -0
  137. /package/dist/{types → mjs/types}/interfaces.js +0 -0
  138. /package/dist/{types → mjs/types}/types.js +0 -0
  139. /package/dist/{utils → mjs/utils}/Util.js +0 -0
  140. /package/dist/{validators → mjs/validators}/inhibitorValidations.js +0 -0
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const dbl_sdk_1 = __importDefault(require("dbl-sdk"));
5
+ const XernerxLog_js_1 = __importDefault(require("../tools/XernerxLog.js"));
6
+ const Handler_js_1 = __importDefault(require("./Handler.js"));
7
+ class IntegrationHandler extends Handler_js_1.default {
8
+ constructor(client) {
9
+ super(client);
10
+ this.dbl = new dbl_sdk_1.default(client, client.config);
11
+ this.readyTimestamp = Number(Date.now());
12
+ }
13
+ async loadIntegrations(options = { votes: true }) {
14
+ this.client.once('ready', async (client) => {
15
+ this.client.dbl.validate = (user) => this.dbl.validate(user);
16
+ if (options.post) {
17
+ this.dbl.post();
18
+ }
19
+ if (options.votes) {
20
+ this.dbl.votes();
21
+ this.client.on('dbl-sync', (client, responses) => {
22
+ this.client.stats.voteCount = responses.voteCount;
23
+ });
24
+ }
25
+ });
26
+ new XernerxLog_js_1.default(this.client).info(`Successfully syncing with top.gg.`);
27
+ }
28
+ }
29
+ exports.default = IntegrationHandler;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.XernerxLog = exports.version = exports.Discord = exports.XernerxExtension = exports.XernerxInhibitor = exports.XernerxEvent = exports.XernerxContextCommand = exports.XernerxSlashCommand = exports.XernerxMessageCommand = exports.XernerxShardClient = exports.XernerxClient = exports.XernerxIntents = void 0;
5
+ const fs = __importStar(require("fs"));
6
+ const version = JSON.parse(fs.readFileSync('node_modules/xernerx/package.json', 'utf-8')).version;
7
+ exports.version = version;
8
+ new XernerxLog_js_1.default(true).update(version, 'https://raw.githubusercontent.com/xernerx/xernerx/master/package.json');
9
+ const XernerxClient_js_1 = __importDefault(require("./client/XernerxClient.js"));
10
+ exports.XernerxClient = XernerxClient_js_1.default;
11
+ const XernerxShardClient_js_1 = __importDefault(require("./client/XernerxShardClient.js"));
12
+ exports.XernerxShardClient = XernerxShardClient_js_1.default;
13
+ const XernerxMessageCommand_js_1 = __importDefault(require("./build/XernerxMessageCommand.js"));
14
+ exports.XernerxMessageCommand = XernerxMessageCommand_js_1.default;
15
+ const XernerxSlashCommand_js_1 = __importDefault(require("./build/XernerxSlashCommand.js"));
16
+ exports.XernerxSlashCommand = XernerxSlashCommand_js_1.default;
17
+ const XernerxContextCommand_js_1 = __importDefault(require("./build/XernerxContextCommand.js"));
18
+ exports.XernerxContextCommand = XernerxContextCommand_js_1.default;
19
+ const XernerxEvent_js_1 = __importDefault(require("./build/XernerxEvent.js"));
20
+ exports.XernerxEvent = XernerxEvent_js_1.default;
21
+ const XernerxInhibitor_js_1 = __importDefault(require("./build/XernerxInhibitor.js"));
22
+ exports.XernerxInhibitor = XernerxInhibitor_js_1.default;
23
+ const XernerxLog_js_1 = __importDefault(require("./tools/XernerxLog.js"));
24
+ exports.XernerxLog = XernerxLog_js_1.default;
25
+ var XernerxIntents_js_1 = require("./tools/XernerxIntents.js");
26
+ Object.defineProperty(exports, "XernerxIntents", { enumerable: true, get: function () { return XernerxIntents_js_1.XernerxIntents; } });
27
+ __exportStar(require("discord.js"), exports);
28
+ __exportStar(require("dumfunctions"), exports);
29
+ const discord_js_1 = __importDefault(require("discord.js"));
30
+ exports.Discord = discord_js_1.default;
31
+ const xernerx_extension_builder_1 = __importDefault(require("xernerx-extension-builder"));
32
+ exports.XernerxExtension = xernerx_extension_builder_1.default;
33
+ __exportStar(require("./types/types.js"), exports);
34
+ __exportStar(require("./types/extenders.js"), exports);
35
+ __exportStar(require("./types/interfaces.js"), exports);
36
+ exports.default = XernerxClient_js_1.default;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.interactionArguments = exports.messageArguments = void 0;
5
+ async function messageArguments(message, command, prefix) {
6
+ const separator = command.separator || ' ', content = message.content
7
+ .replace(new RegExp(`${prefix} +?`), '')
8
+ .split(separator)
9
+ .slice(1);
10
+ let args = {}, flags = {};
11
+ if (command.flags)
12
+ command.flags.map((flag) => {
13
+ if (!flags)
14
+ flags = {};
15
+ if (content.includes(flag.match))
16
+ flags[flag.name] = true;
17
+ else
18
+ flags[flag.name] = false;
19
+ const index = content.indexOf(flag.match);
20
+ if (index > 0)
21
+ content.splice(index, 1);
22
+ });
23
+ if (command.args)
24
+ for (const argument of command.args) {
25
+ const element = content.at(0) || null;
26
+ if (!element) {
27
+ if (typeof argument.default === 'function')
28
+ args[argument.name] = argument.default(message);
29
+ args[argument.name] = argument.default || null;
30
+ continue;
31
+ }
32
+ if (argument.type === 'option')
33
+ argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
34
+ if (argument.type === 'number')
35
+ args[argument.name] = parseInt(element);
36
+ if (argument.type === 'integer')
37
+ args[argument.name] = parseInt(element);
38
+ if (argument.type === 'boolean')
39
+ args[argument.name] = element === 'true' ? true : false;
40
+ if (argument.type === 'confirm')
41
+ args[argument.name] = element === 'yes' ? 'yes' : 'no';
42
+ if (argument.type === 'string')
43
+ args[argument.name] = element;
44
+ if (argument.type === 'channel') {
45
+ try {
46
+ const channel = await message.client.channels.fetch(element);
47
+ args[argument.name] = channel;
48
+ }
49
+ catch (e) {
50
+ args[argument.name] = null;
51
+ }
52
+ }
53
+ if (argument.type === 'guild') {
54
+ try {
55
+ const guild = await message.client.guilds.fetch(element);
56
+ args[argument.name] = guild;
57
+ }
58
+ catch (e) {
59
+ args[argument.name] = null;
60
+ }
61
+ }
62
+ if (argument.type === 'mentionable') {
63
+ (await Promise.all([message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) => req
64
+ ? req
65
+ .fetch(element)
66
+ .then((r) => r)
67
+ .catch(() => null)
68
+ : null))).map((mentionable) => {
69
+ if (!args)
70
+ args = {};
71
+ if (mentionable)
72
+ return (args[argument.name] = mentionable);
73
+ else
74
+ return (args[argument.name] = null);
75
+ });
76
+ }
77
+ if (argument.type === 'role') {
78
+ try {
79
+ const role = await message.guild?.roles.fetch(element);
80
+ args[argument.name] = role;
81
+ }
82
+ catch (e) {
83
+ args[argument.name] = null;
84
+ }
85
+ }
86
+ if (argument.type === 'user') {
87
+ try {
88
+ const user = await message.client.users.fetch(element);
89
+ args[argument.name] = user;
90
+ }
91
+ catch (e) {
92
+ args[argument.name] = null;
93
+ }
94
+ }
95
+ if (argument.type === 'member') {
96
+ try {
97
+ const member = await message.guild?.members.fetch(element);
98
+ args[argument.name] = member;
99
+ }
100
+ catch (e) {
101
+ args[argument.name] = null;
102
+ }
103
+ }
104
+ if (argument.type === 'message') {
105
+ try {
106
+ const msg = await message.channel?.messages.fetch(element);
107
+ args[argument.name] = msg;
108
+ }
109
+ catch (e) {
110
+ args[argument.name] = null;
111
+ }
112
+ }
113
+ if (argument.type === 'list') {
114
+ let separator = String(argument.separator) || ',';
115
+ if (separator.startsWith('/') && separator.endsWith('/'))
116
+ separator = separator.replace(/^\/|\/$/gim, '');
117
+ const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
118
+ if (!argument.content)
119
+ args[argument.name] = items;
120
+ else {
121
+ const contents = argument.content.map((content) => content.toLowerCase()), itemList = [];
122
+ items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
123
+ args[argument.name] = itemList;
124
+ break;
125
+ }
126
+ }
127
+ if (argument.type === 'rest') {
128
+ args[argument.name] = content.join(separator);
129
+ break;
130
+ }
131
+ content.splice(0, 1);
132
+ }
133
+ if (!command.flags)
134
+ flags = null;
135
+ if (!command.args)
136
+ args = null;
137
+ return { args, flags };
138
+ }
139
+ exports.messageArguments = messageArguments;
140
+ async function interactionArguments(interaction, command) {
141
+ if (command.filetype === 'SlashCommand') {
142
+ const options = {};
143
+ let args = interaction?.options?._hoistedOptions, group = interaction?.options?._group, subcommand = interaction?.options?._subcommand;
144
+ if (interaction.options._hoistedOptions) {
145
+ for (const option of interaction.options._hoistedOptions) {
146
+ options[option.name] = option.member || option.channel || option.user || option.role || option.value;
147
+ }
148
+ args = options;
149
+ }
150
+ return { args, group, subcommand };
151
+ }
152
+ if (command.filetype === 'ContextCommand') {
153
+ if (command.type === 'user')
154
+ return await interaction.client.users.fetch(interaction.targetId);
155
+ if (command.type === 'message')
156
+ return await interaction.channel.messages.fetch(interaction.targetId);
157
+ }
158
+ }
159
+ exports.interactionArguments = interactionArguments;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const discord_js_1 = require("discord.js");
5
+ class Cooldowns {
6
+ constructor(client, collections = []) {
7
+ this._client = client;
8
+ this.collections = {
9
+ commands: new discord_js_1.Collection(),
10
+ };
11
+ for (const collection of collections) {
12
+ this.collections[collection] = new discord_js_1.Collection();
13
+ }
14
+ }
15
+ add(collection, id, value) {
16
+ if (!this.collections[collection])
17
+ return `${collection} collection does not exist!`;
18
+ return this.collections[collection].set(id, value);
19
+ }
20
+ delete(collection, id) {
21
+ if (!this.collections[collection])
22
+ return `${collection} collection does not exist!`;
23
+ return this.collections[collection].delete(id);
24
+ }
25
+ has(id) {
26
+ const collected = {};
27
+ for (const [name, collection] of Object.entries(this.collections)) {
28
+ if (collection.has(id))
29
+ collected[name] = collection;
30
+ else
31
+ continue;
32
+ }
33
+ return collected;
34
+ }
35
+ }
36
+ exports.default = Cooldowns;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ class XernerxError {
5
+ name;
6
+ message;
7
+ stack;
8
+ constructor(message, error) {
9
+ this.name = 'XernerxError';
10
+ this.message = message || null;
11
+ this.stack = error || new Error().stack;
12
+ }
13
+ }
14
+ exports.default = XernerxError;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.XernerxIntents = void 0;
5
+ exports.XernerxIntents = {
6
+ Default: [
7
+ 'Guilds',
8
+ 'GuildModeration',
9
+ 'GuildBans',
10
+ 'GuildEmojisAndStickers',
11
+ 'GuildIntegrations',
12
+ 'GuildWebhooks',
13
+ 'GuildInvites',
14
+ 'GuildVoiceStates',
15
+ 'GuildMessages',
16
+ 'GuildMessageReactions',
17
+ 'GuildMessageTyping',
18
+ 'DirectMessages',
19
+ 'DirectMessageReactions',
20
+ 'DirectMessageTyping',
21
+ 'GuildScheduledEvents',
22
+ 'AutoModerationConfiguration',
23
+ 'AutoModerationExecution',
24
+ ],
25
+ All: [''],
26
+ };
27
+ exports.XernerxIntents.All = [...exports.XernerxIntents.Default, 'GuildMembers', 'GuildPresences', 'MessageContent'];
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const dumfunctions_1 = require("dumfunctions");
5
+ class XernerxLog {
6
+ constructor(client) {
7
+ this.client = client;
8
+ if (client == true || (typeof client.settings.log == 'boolean' && client.settings.log)) {
9
+ this.errorLog = true;
10
+ this.infoLog = true;
11
+ this.warnLog = true;
12
+ }
13
+ else {
14
+ this.errorLog = client.settings.log?.error;
15
+ this.infoLog = client.settings.log?.info;
16
+ this.warnLog = client.settings.log?.warn;
17
+ this.readyLog = client.settings.log?.ready;
18
+ this.tableLog = client.settings.log?.table;
19
+ }
20
+ this.time = () => String(new Date()).split(/ +/)[4];
21
+ this.ram = () => Math.round(process.memoryUsage().rss / 1000000);
22
+ this.shard = '';
23
+ process.on('message', (message) => {
24
+ if (message.type == 'xernerx')
25
+ this.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
26
+ });
27
+ this.base = (type, message) => `${type == 'info' ? `✔️ | ${this.purple('Xernerx')}` : type == `error` ? `❗ | ${this.red('Xernerx')}` : type == `update` ? `⬆️ | ${this.blue('Xernerx')}` : `⚠️ | ${this.yellow('Xernerx')}`} | ${this.cyan(this.time())} | ${this.cyan(this.ram())}mb | ${this.client.stats?.shardCount > 1 ? `${this.cyan(this.client.stats.shardId)} | ` : ''}${message}`;
28
+ }
29
+ info(message, force = false) {
30
+ return this.infoLog || force ? console.info(this.base('info', message)) : null;
31
+ }
32
+ warn(message) {
33
+ return this.warnLog ? console.warn(this.base('warn', message)) : null;
34
+ }
35
+ async update(version, url) {
36
+ const pkg = await fetch(url)
37
+ .then(async (res) => await res.json())
38
+ .catch(() => ({ version }));
39
+ if (version !== pkg.version)
40
+ console.info(this.base('update', `A new version for ${pkg.name} is available, you're using version ${this.cyan(version)}, new version is ${this.cyan(pkg.version)}, run ${dumfunctions_1.Style.log(`npm i ${pkg.name}@${pkg.version}`, {
41
+ color: dumfunctions_1.Style.BackgroundColor.Grey,
42
+ })} to update to the latest version.`));
43
+ }
44
+ error(message, error) {
45
+ return this.errorLog ? console.error(this.base('error', message), error) : null;
46
+ }
47
+ ready() {
48
+ if (typeof this.client == 'boolean')
49
+ return;
50
+ const client = this.client;
51
+ this.client.prependOnceListener('ready', async (synced) => {
52
+ this.info(`${dumfunctions_1.Style.log(synced.user.tag, { color: dumfunctions_1.Style.TextColor.Blue })} is now ${this.green('online')}, watching ${this.cyan(String(client.guilds.cache.size))} guild${client.guilds.cache.size > 1 ? 's' : ''}, using ${client.settings.local ? this.blue((await client.guilds.fetch(client.settings.local))?.name) : 'none'} as local guild.`, this.readyLog);
53
+ const files = [];
54
+ for (const [id, data] of client.commands.message) {
55
+ files.push(data);
56
+ id;
57
+ }
58
+ for (const [id, data] of client.commands.slash) {
59
+ files.push(data);
60
+ id;
61
+ }
62
+ for (const [id, data] of client.commands.context) {
63
+ files.push(data);
64
+ id;
65
+ }
66
+ for (const [id, data] of client.events) {
67
+ files.push(data);
68
+ id;
69
+ }
70
+ for (const [id, data] of client.inhibitors) {
71
+ files.push(data);
72
+ id;
73
+ }
74
+ if (this.tableLog) {
75
+ console.table(files, this.tableLog);
76
+ }
77
+ });
78
+ }
79
+ cyan(string) {
80
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Cyan });
81
+ }
82
+ blue(string) {
83
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Blue });
84
+ }
85
+ yellow(string) {
86
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Yellow });
87
+ }
88
+ purple(string) {
89
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Purple });
90
+ }
91
+ red(string) {
92
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Red });
93
+ }
94
+ green(string) {
95
+ return dumfunctions_1.Style.log(String(string), { color: dumfunctions_1.Style.TextColor.Green });
96
+ }
97
+ }
98
+ exports.default = XernerxLog;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ class XernerxText {
5
+ user(user) {
6
+ if (typeof user == 'object')
7
+ user = user.id;
8
+ return `<@${user}>`;
9
+ }
10
+ channel(channel) {
11
+ if (typeof channel == 'object')
12
+ channel = channel.id;
13
+ return `<#${channel}>`;
14
+ }
15
+ role(role) {
16
+ if (typeof role == 'object')
17
+ role = role.id;
18
+ return `<@&${role}>`;
19
+ }
20
+ emoji(emoji, animated = false) {
21
+ if (typeof emoji == 'object')
22
+ emoji = emoji.id;
23
+ return `<${animated ? 'a' : ''}:${emoji}>`;
24
+ }
25
+ member(member) {
26
+ if (typeof member == 'object')
27
+ member = member.id;
28
+ return `<@!${member}>`;
29
+ }
30
+ timestamp(timestamp = Date.now(), format = 'R') {
31
+ if (typeof timestamp == 'string')
32
+ timestamp = Number(timestamp);
33
+ if (isNaN(timestamp))
34
+ return 'Invalid Date';
35
+ return `<t:${timestamp}:${format}>`;
36
+ }
37
+ codeBlock(code, language) {
38
+ return `\`\`\`${language}
39
+ ${code}
40
+ \`\`\``;
41
+ }
42
+ iCodeBlock(code) {
43
+ return `\`${code}\``;
44
+ }
45
+ bold(text) {
46
+ return `**${text}**`;
47
+ }
48
+ italic(text) {
49
+ return `*${text}*`;
50
+ }
51
+ underline(text) {
52
+ return `__${text}__`;
53
+ }
54
+ strike(text) {
55
+ return `~~${text}~~`;
56
+ }
57
+ spoiler(text) {
58
+ return `||${text}||`;
59
+ }
60
+ quote(text) {
61
+ return `> ${text}`;
62
+ }
63
+ blockQuote(text) {
64
+ return `>>> ${text}`;
65
+ }
66
+ hyperlink(text, url) {
67
+ return `[${text}](${url})`;
68
+ }
69
+ // public static HyperlinkWithTooltip(text: string, url: string, tooltip: string) {
70
+ // return `[${text}](${url} "${tooltip}")`;
71
+ // }
72
+ // public static HyperlinkWithTooltipAndImage(text: string, url: string, tooltip: string, imageUrl: string) {
73
+ // return `[${text}](${url} "${tooltip}":${imageUrl})`;
74
+ // }
75
+ // public static HyperlinkWithImage(text: string, url: string, imageUrl: string) {
76
+ // return `[${text}](${url}:${imageUrl})`;
77
+ // }
78
+ Progressbar(min, max, cur, options = {}) {
79
+ if (!options.fill)
80
+ options.fill = '█';
81
+ if (!options.fade)
82
+ options.fade = '▓▒';
83
+ if (!options.empty)
84
+ options.empty = '░';
85
+ const length = options.length || 20, percentage = cur / max, filledLength = Math.round(length * percentage), emptyLength = length - filledLength;
86
+ if (!options.percentage)
87
+ return '`' + options.fill.repeat(filledLength) + options.empty.repeat(emptyLength) + '`';
88
+ else
89
+ return '`' + options.fill.repeat(filledLength) + options.empty.repeat(emptyLength) + '` ' + `\`${percentage * 100}%\``;
90
+ }
91
+ }
92
+ exports.default = XernerxText;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -11,8 +11,9 @@ export default class ClientUtil extends Util {
11
11
  constructor(client: XernerxClient);
12
12
  setPresence(options: PresenceOptions): import("discord.js").ClientPresence | undefined;
13
13
  private resolveCooldown;
14
- resolveCommand(options: ResolveCommandOptions): XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand | Collection<string, XernerxMessageCommand | XernerxSlashCommand | XernerxContextCommand>;
14
+ resolveCommand(options: ResolveCommandOptions): XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand | Collection<string, XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand>;
15
15
  resolveChannel(query: string | Record<string, string>): Promise<import("discord.js").Channel | null>;
16
16
  resolveGuild(query: string | Record<string, string>): Promise<import("discord.js").Guild | null>;
17
17
  uptime(timestamp?: number | null): string;
18
+ commands(): (XernerxSlashCommand | XernerxContextCommand | XernerxMessageCommand)[];
18
19
  }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /** @format */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const discord_js_1 = require("discord.js");
5
+ const setPresence_js_1 = __importDefault(require("../functions/setPresence.js"));
6
+ const Util_js_1 = __importDefault(require("./Util.js"));
7
+ class ClientUtil extends Util_js_1.default {
8
+ constructor(client) {
9
+ super(client);
10
+ }
11
+ setPresence(options) {
12
+ return (0, setPresence_js_1.default)(this.client, options);
13
+ }
14
+ // @ts-ignore
15
+ resolveCooldown() { }
16
+ resolveCommand(options) {
17
+ const commands = [], collection = new discord_js_1.Collection();
18
+ if (options?.type == 'MessageCommand' || !options?.type)
19
+ commands.push(...this.client.commands.message);
20
+ if (options?.type == 'Interaction' || options?.type == 'SlashCommand' || !options?.type)
21
+ commands.push(...this.client.commands.slash);
22
+ if (options?.type == 'Interaction' || options?.type == 'ContextCommand' || !options?.type)
23
+ commands.push(...this.client.commands.context);
24
+ commands.map(([name, command]) => collection.set(name, command));
25
+ if (options?.name) {
26
+ return collection.get(options.name) || null;
27
+ }
28
+ else
29
+ return collection;
30
+ }
31
+ async resolveChannel(query) {
32
+ if (typeof query == 'object')
33
+ query = query.id;
34
+ try {
35
+ let channel = this.client.channels.cache.find((channel) => channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null) || null;
36
+ if (!channel)
37
+ channel = (await this.client.channels.fetch(query)) || null;
38
+ return channel;
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ }
44
+ async resolveGuild(query) {
45
+ if (typeof query == 'object')
46
+ query = query.id;
47
+ try {
48
+ let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
49
+ if (!guild)
50
+ guild = (await this.client.guilds.fetch(query)) || null;
51
+ return guild;
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ }
57
+ uptime(timestamp) {
58
+ if (!timestamp)
59
+ timestamp = this.client.uptime || 0;
60
+ let totalSeconds = timestamp / 1000;
61
+ let years = Math.floor(totalSeconds / 31536000);
62
+ totalSeconds %= 31536000;
63
+ let days = Math.floor(totalSeconds / 86400);
64
+ totalSeconds %= 86400;
65
+ let hours = Math.floor(totalSeconds / 3600);
66
+ totalSeconds %= 3600;
67
+ let minutes = Math.floor(totalSeconds / 60);
68
+ let seconds = Math.floor(totalSeconds % 60);
69
+ if (years >= 1)
70
+ return `${years}y ${days}d ${hours}h ${minutes}m`;
71
+ else if (days >= 1)
72
+ return `${days}d ${hours}h ${minutes}m`;
73
+ else if (hours >= 1)
74
+ return `${hours}h ${minutes}m`;
75
+ else if (minutes >= 1)
76
+ return `${minutes}m ${seconds}s`;
77
+ else
78
+ return `${seconds}s`;
79
+ }
80
+ commands() {
81
+ return [...this.client.commands.context.toJSON(), ...this.client.commands.slash.toJSON(), ...this.client.commands.message.toJSON()];
82
+ }
83
+ }
84
+ exports.default = ClientUtil;
@@ -2,7 +2,7 @@
2
2
  import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessageCreateOptions, MessagePayload } from 'discord.js';
3
3
  import XernerxClient from '../client/XernerxClient.js';
4
4
  import { ContextCommandArguments, PaginatorOptions, SlashCommandArguments } from '../types/interfaces.js';
5
- import { XernerxInteraction } from '../types/types.js';
5
+ import { PermissionNames, XernerxInteraction } from '../types/types.js';
6
6
  import Util from './Util.js';
7
7
  import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
8
8
  type MimicOptions = {
@@ -18,7 +18,8 @@ export default class InteractionUtil extends Util {
18
18
  send(content: any): Promise<import("discord.js").Message<false> | import("discord.js").Message<true> | undefined>;
19
19
  reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import("discord.js").InteractionResponse<boolean> | import("discord.js").Message<boolean>>;
20
20
  mimic(user: XernerxUser | string, interaction: MessageCreateOptions, options: MimicOptions): Promise<void>;
21
- private commandName;
22
21
  paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import("discord.js").Message<false> | import("discord.js").Message<true>>;
22
+ commands(): import("@discordjs/collection").Collection<string, import("../main.js").XernerxSlashCommand> | import("@discordjs/collection").Collection<string, import("../main.js").XernerxContextCommand>;
23
+ permissionCheck(type: 'user' | 'client', permissions: Array<PermissionNames>): boolean;
23
24
  }
24
25
  export {};