xernerx 3.5.1 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build → cjs/build}/ContextCommandBuilder.d.ts +31 -28
- package/dist/cjs/build/ContextCommandBuilder.js +97 -0
- package/dist/cjs/build/EventBuilder.js +44 -0
- package/dist/{build → cjs/build}/InhibitorBuilder.d.ts +1 -1
- package/dist/cjs/build/InhibitorBuilder.js +37 -0
- package/dist/{build → cjs/build}/MessageCommandBuilder.d.ts +23 -17
- package/dist/cjs/build/MessageCommandBuilder.js +100 -0
- package/dist/{build → cjs/build}/SlashCommandBuilder.d.ts +25 -18
- package/dist/cjs/build/SlashCommandBuilder.js +169 -0
- package/dist/{client → cjs/client}/XernerxClient.d.ts +1 -0
- package/dist/cjs/client/XernerxClient.js +120 -0
- package/dist/{handlers → cjs/handlers}/CommandHandler.js +11 -8
- package/dist/{handlers → cjs/handlers}/EventHandler.js +6 -3
- package/dist/cjs/handlers/Handler.js +308 -0
- package/dist/{handlers → cjs/handlers}/InhibitorHandler.js +6 -3
- package/dist/cjs/handlers/WebhookHandler.d.ts +7 -0
- package/dist/cjs/handlers/WebhookHandler.js +23 -0
- package/dist/{main.d.ts → cjs/main.d.ts} +15 -1
- package/dist/cjs/main.js +112 -0
- package/dist/{models → cjs/models}/CommandArguments.d.ts +1 -1
- package/dist/{models → cjs/models}/CommandArguments.js +37 -52
- package/dist/cjs/models/Events.js +309 -0
- package/dist/cjs/models/Extensions.js +26 -0
- package/dist/cjs/models/XernerxUser.d.ts +2 -0
- package/dist/cjs/models/XernerxUser.js +12 -0
- package/dist/{tools → cjs/tools}/XernerxError.js +4 -1
- package/dist/{tools → cjs/tools}/package.d.ts +4 -9
- package/dist/{tools → cjs/tools}/package.js +14 -17
- package/dist/cjs/types/enums.d.ts +44 -0
- package/dist/cjs/types/enums.js +38 -0
- package/dist/{types → cjs/types}/interfaces.d.ts +2 -0
- package/dist/cjs/types/interfaces.js +2 -0
- package/dist/{types → cjs/types}/options.d.ts +13 -0
- package/dist/cjs/types/options.js +2 -0
- package/dist/{types → cjs/types}/types.d.ts +38 -10
- package/dist/cjs/types/types.js +2 -0
- package/dist/{utils → cjs/utils}/ClientUtil.d.ts +1 -0
- package/dist/{utils → cjs/utils}/ClientUtil.js +73 -84
- package/dist/{utils → cjs/utils}/CommandUtil.d.ts +4 -2
- package/dist/{utils → cjs/utils}/CommandUtil.js +102 -103
- package/dist/{validators → cjs/validators}/CommandValidations.d.ts +6 -1
- package/dist/{validators → cjs/validators}/CommandValidations.js +36 -50
- package/dist/{validators → cjs/validators}/InhibitorValidations.js +12 -14
- package/dist/mjs/build/ContextCommandBuilder.d.ts +63 -0
- package/dist/mjs/build/ContextCommandBuilder.js +97 -0
- package/dist/mjs/build/EventBuilder.d.ts +21 -0
- package/dist/mjs/build/EventBuilder.js +44 -0
- package/dist/mjs/build/InhibitorBuilder.d.ts +19 -0
- package/dist/mjs/build/InhibitorBuilder.js +37 -0
- package/dist/mjs/build/MessageCommandBuilder.d.ts +59 -0
- package/dist/mjs/build/MessageCommandBuilder.js +100 -0
- package/dist/mjs/build/SlashCommandBuilder.d.ts +65 -0
- package/dist/mjs/build/SlashCommandBuilder.js +169 -0
- package/dist/mjs/client/XernerxClient.d.ts +29 -0
- package/dist/mjs/client/XernerxClient.js +120 -0
- package/dist/mjs/handlers/CommandHandler.d.ts +27 -0
- package/dist/mjs/handlers/CommandHandler.js +45 -0
- package/dist/mjs/handlers/EventHandler.d.ts +13 -0
- package/dist/mjs/handlers/EventHandler.js +19 -0
- package/dist/mjs/handlers/Handler.d.ts +57 -0
- package/dist/mjs/handlers/Handler.js +308 -0
- package/dist/mjs/handlers/InhibitorHandler.d.ts +18 -0
- package/dist/mjs/handlers/InhibitorHandler.js +24 -0
- package/dist/mjs/handlers/WebhookHandler.d.ts +7 -0
- package/dist/mjs/handlers/WebhookHandler.js +23 -0
- package/dist/{main.js → mjs/main.d.ts} +20 -18
- package/dist/mjs/main.js +112 -0
- package/dist/mjs/models/CommandArguments.d.ts +17 -0
- package/dist/mjs/models/CommandArguments.js +106 -0
- package/dist/mjs/models/Events.d.ts +24 -0
- package/dist/mjs/models/Events.js +309 -0
- package/dist/mjs/models/Extensions.d.ts +7 -0
- package/dist/mjs/models/Extensions.js +26 -0
- package/dist/mjs/models/XernerxUser.d.ts +2 -0
- package/dist/mjs/models/XernerxUser.js +12 -0
- package/dist/mjs/tools/XernerxError.d.ts +5 -0
- package/dist/mjs/tools/XernerxError.js +11 -0
- package/dist/mjs/tools/package.d.ts +44 -0
- package/dist/mjs/tools/package.js +45 -0
- package/dist/mjs/types/enums.d.ts +44 -0
- package/dist/mjs/types/enums.js +38 -0
- package/dist/mjs/types/interfaces.d.ts +27 -0
- package/dist/mjs/types/interfaces.js +2 -0
- package/dist/mjs/types/options.d.ts +254 -0
- package/dist/mjs/types/options.js +2 -0
- package/dist/mjs/types/types.d.ts +62 -0
- package/dist/mjs/types/types.js +2 -0
- package/dist/mjs/utils/ClientUtil.d.ts +26 -0
- package/dist/mjs/utils/ClientUtil.js +211 -0
- package/dist/mjs/utils/CommandUtil.d.ts +58 -0
- package/dist/mjs/utils/CommandUtil.js +247 -0
- package/dist/mjs/validators/CommandValidations.d.ts +12 -0
- package/dist/mjs/validators/CommandValidations.js +169 -0
- package/dist/mjs/validators/InhibitorValidations.d.ts +11 -0
- package/dist/mjs/validators/InhibitorValidations.js +40 -0
- package/package.json +11 -15
- package/dist/build/ContextCommandBuilder.js +0 -93
- package/dist/build/EventBuilder.js +0 -34
- package/dist/build/InhibitorBuilder.js +0 -27
- package/dist/build/MessageCommandBuilder.js +0 -90
- package/dist/build/SlashCommandBuilder.js +0 -125
- package/dist/client/XernerxClient.js +0 -101
- package/dist/handlers/Handler.js +0 -250
- package/dist/main.cjs +0 -2023
- package/dist/models/Events.js +0 -294
- package/dist/models/Extensions.js +0 -23
- package/dist/types/enums.d.ts +0 -35
- package/dist/types/enums.js +0 -35
- package/dist/types/interfaces.js +0 -1
- package/dist/types/options.js +0 -1
- package/dist/types/types.js +0 -1
- package/dist/validators/Shapes.js +0 -1
- /package/dist/{build → cjs/build}/EventBuilder.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/CommandHandler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/EventHandler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/Handler.d.ts +0 -0
- /package/dist/{handlers → cjs/handlers}/InhibitorHandler.d.ts +0 -0
- /package/dist/{models → cjs/models}/Events.d.ts +0 -0
- /package/dist/{models → cjs/models}/Extensions.d.ts +0 -0
- /package/dist/{tools → cjs/tools}/XernerxError.d.ts +0 -0
- /package/dist/{validators → cjs/validators}/InhibitorValidations.d.ts +0 -0
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.default = {
|
|
2
4
|
name: 'xernerx',
|
|
3
|
-
version: '3.5.
|
|
4
|
-
type: 'module',
|
|
5
|
+
version: '3.5.2',
|
|
5
6
|
description: 'A bot framework for discord.js.',
|
|
6
|
-
main: 'dist/main.js',
|
|
7
|
+
main: 'dist/cjs/main.js',
|
|
8
|
+
module: 'dist/mjs/main.js',
|
|
7
9
|
keywords: ['discord.js', 'discord', 'framework', 'mjs', 'esm', 'cjs', 'ts'],
|
|
8
10
|
author: 'Dummi',
|
|
9
11
|
license: 'MIT',
|
|
10
12
|
homepage: 'https://xernerx.github.io/xernerx/home.html',
|
|
11
13
|
packageManager: 'npm@8.5.5',
|
|
12
|
-
exports: {
|
|
13
|
-
import: './dist/main.js',
|
|
14
|
-
require: './dist/main.cjs',
|
|
15
|
-
types: './types',
|
|
16
|
-
node: null,
|
|
17
|
-
default: null,
|
|
18
|
-
},
|
|
19
14
|
scripts: {
|
|
20
15
|
start: 'npm i && npm fund && npm audit fix --force && npm link && tsc -w',
|
|
21
16
|
patch: 'npm run write && git add . && npm run commit && npm version patch && npm publish && git push',
|
|
@@ -23,8 +18,11 @@ export default {
|
|
|
23
18
|
major: 'npm run write && git add . && npm run commit && npm version major && npm publish && git push',
|
|
24
19
|
site: 'git add docs && npm run commit && git push',
|
|
25
20
|
commit: 'node ../.scripts/commit.js',
|
|
26
|
-
write: 'npm run build && node ../.scripts/rewritePackage.js ',
|
|
27
|
-
|
|
21
|
+
write: 'npm run build && npm run format && node ../.scripts/rewritePackage.js ',
|
|
22
|
+
format: 'npx prettier --write src dist',
|
|
23
|
+
build: 'npm run build:esm && npm run build:cjs',
|
|
24
|
+
'build:esm': 'tsc',
|
|
25
|
+
'build:cjs': 'tsc --module CommonJS --outDir dist/cjs',
|
|
28
26
|
},
|
|
29
27
|
repository: {
|
|
30
28
|
type: 'git',
|
|
@@ -35,14 +33,13 @@ export default {
|
|
|
35
33
|
},
|
|
36
34
|
dependencies: {
|
|
37
35
|
'@sapphire/shapeshift': '^3.8.1',
|
|
38
|
-
'discord.js': '^14.7.
|
|
39
|
-
dumfunctions: '^2.
|
|
40
|
-
'xernerx-extension-builder': '^0.0.
|
|
36
|
+
'discord.js': '^14.7.1',
|
|
37
|
+
dumfunctions: '^2.1.2',
|
|
38
|
+
'xernerx-extension-builder': '^0.0.8',
|
|
41
39
|
zod: '^3.20.6',
|
|
42
40
|
},
|
|
43
41
|
devDependencies: {
|
|
44
42
|
prettier: '^2.8.4',
|
|
45
|
-
tsup: '^6.6.0',
|
|
46
43
|
typescript: '^4.9.5',
|
|
47
44
|
},
|
|
48
45
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SlashCommandStringOption,
|
|
3
|
+
SlashCommandNumberOption,
|
|
4
|
+
SlashCommandIntegerOption,
|
|
5
|
+
SlashCommandBooleanOption,
|
|
6
|
+
SlashCommandUserOption,
|
|
7
|
+
SlashCommandChannelOption,
|
|
8
|
+
SlashCommandRoleOption,
|
|
9
|
+
SlashCommandMentionableOption,
|
|
10
|
+
} from 'discord.js';
|
|
11
|
+
export declare enum InhibitorType {
|
|
12
|
+
Member = 'Member',
|
|
13
|
+
User = 'User',
|
|
14
|
+
Guild = 'Guild',
|
|
15
|
+
SlashCommand = 'SlashCommand',
|
|
16
|
+
MessageCommand = 'MessageCommand',
|
|
17
|
+
ContextCommand = 'ContextCommand',
|
|
18
|
+
Command = 'Command',
|
|
19
|
+
Message = 'Message',
|
|
20
|
+
Interaction = 'Interaction',
|
|
21
|
+
Channel = 'Channel',
|
|
22
|
+
}
|
|
23
|
+
export declare enum CommandType {
|
|
24
|
+
Message = 'MessageCommand',
|
|
25
|
+
Slash = 'SlashCommand',
|
|
26
|
+
Context = 'ContextCommand',
|
|
27
|
+
Event = 'Event',
|
|
28
|
+
Inhibitor = 'Inhibitor',
|
|
29
|
+
MessageCommand = 'MessageCommand',
|
|
30
|
+
SlashCommand = 'SlashCommand',
|
|
31
|
+
ContextCommand = 'ContextCommand',
|
|
32
|
+
}
|
|
33
|
+
export declare enum ContextCommandType {
|
|
34
|
+
Message = 3,
|
|
35
|
+
User = 2,
|
|
36
|
+
}
|
|
37
|
+
export declare enum EventEmitterType {
|
|
38
|
+
Client = 'client',
|
|
39
|
+
Rest = 'rest',
|
|
40
|
+
Process = 'process',
|
|
41
|
+
}
|
|
42
|
+
export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
|
|
43
|
+
export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
|
|
44
|
+
export type SlashArgumentTypes = 'String' | 'Number' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Mentionable' | 'Integer';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.EventEmitterType = exports.ContextCommandType = exports.CommandType = exports.InhibitorType = void 0;
|
|
4
|
+
var InhibitorType;
|
|
5
|
+
(function (InhibitorType) {
|
|
6
|
+
InhibitorType['Member'] = 'Member';
|
|
7
|
+
InhibitorType['User'] = 'User';
|
|
8
|
+
InhibitorType['Guild'] = 'Guild';
|
|
9
|
+
InhibitorType['SlashCommand'] = 'SlashCommand';
|
|
10
|
+
InhibitorType['MessageCommand'] = 'MessageCommand';
|
|
11
|
+
InhibitorType['ContextCommand'] = 'ContextCommand';
|
|
12
|
+
InhibitorType['Command'] = 'Command';
|
|
13
|
+
InhibitorType['Message'] = 'Message';
|
|
14
|
+
InhibitorType['Interaction'] = 'Interaction';
|
|
15
|
+
InhibitorType['Channel'] = 'Channel';
|
|
16
|
+
})((InhibitorType = exports.InhibitorType || (exports.InhibitorType = {})));
|
|
17
|
+
var CommandType;
|
|
18
|
+
(function (CommandType) {
|
|
19
|
+
CommandType['Message'] = 'MessageCommand';
|
|
20
|
+
CommandType['Slash'] = 'SlashCommand';
|
|
21
|
+
CommandType['Context'] = 'ContextCommand';
|
|
22
|
+
CommandType['Event'] = 'Event';
|
|
23
|
+
CommandType['Inhibitor'] = 'Inhibitor';
|
|
24
|
+
CommandType['MessageCommand'] = 'MessageCommand';
|
|
25
|
+
CommandType['SlashCommand'] = 'SlashCommand';
|
|
26
|
+
CommandType['ContextCommand'] = 'ContextCommand';
|
|
27
|
+
})((CommandType = exports.CommandType || (exports.CommandType = {})));
|
|
28
|
+
var ContextCommandType;
|
|
29
|
+
(function (ContextCommandType) {
|
|
30
|
+
ContextCommandType[(ContextCommandType['Message'] = 3)] = 'Message';
|
|
31
|
+
ContextCommandType[(ContextCommandType['User'] = 2)] = 'User';
|
|
32
|
+
})((ContextCommandType = exports.ContextCommandType || (exports.ContextCommandType = {})));
|
|
33
|
+
var EventEmitterType;
|
|
34
|
+
(function (EventEmitterType) {
|
|
35
|
+
EventEmitterType['Client'] = 'client';
|
|
36
|
+
EventEmitterType['Rest'] = 'rest';
|
|
37
|
+
EventEmitterType['Process'] = 'process';
|
|
38
|
+
})((EventEmitterType = exports.EventEmitterType || (exports.EventEmitterType = {})));
|
|
@@ -5,6 +5,7 @@ import InhibitorHandler from '../handlers/InhibitorHandler.js';
|
|
|
5
5
|
import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
|
|
6
6
|
import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
|
|
7
7
|
import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
|
|
8
|
+
import WebhookHandler from '../handlers/WebhookHandler.js';
|
|
8
9
|
export interface ClientCommands {
|
|
9
10
|
message: Collection<string, MessageCommandBuilder>;
|
|
10
11
|
slash: Collection<string, SlashCommandBuilder>;
|
|
@@ -22,4 +23,5 @@ export interface ClientModules {
|
|
|
22
23
|
commandHandler: CommandHandler;
|
|
23
24
|
eventHandler: EventHandler;
|
|
24
25
|
inhibitorHandler: InhibitorHandler;
|
|
26
|
+
webhookHandler: WebhookHandler;
|
|
25
27
|
}
|
|
@@ -46,6 +46,7 @@ export interface HandlerOptions {
|
|
|
46
46
|
context?: ContextCommandHandlerOptions;
|
|
47
47
|
events?: EventHandlerOptions;
|
|
48
48
|
inhibitors?: InhibitorHandlerOptions;
|
|
49
|
+
webhook?: WebhookOptions;
|
|
49
50
|
}
|
|
50
51
|
export interface ExtensionOptions {
|
|
51
52
|
extensions: Array<XernerxExtensionBuilder>;
|
|
@@ -239,3 +240,15 @@ export interface InhibitorOptions {
|
|
|
239
240
|
name: string;
|
|
240
241
|
type: InhibitorType;
|
|
241
242
|
}
|
|
243
|
+
export interface WebhookOptions {
|
|
244
|
+
topgg: {
|
|
245
|
+
token: string;
|
|
246
|
+
};
|
|
247
|
+
dbl: {
|
|
248
|
+
token: string;
|
|
249
|
+
};
|
|
250
|
+
config: {
|
|
251
|
+
emits: boolean;
|
|
252
|
+
logs: boolean;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
@@ -19,16 +19,44 @@ export interface XernerxInteraction extends InteractionResponse {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
export interface XernerxUser extends User {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface XernerxRole extends Role {
|
|
25
|
-
}
|
|
26
|
-
export interface XernerxTextChannel extends TextChannel {
|
|
27
|
-
}
|
|
28
|
-
export interface XernerxGuild extends Guild {
|
|
29
|
-
}
|
|
30
|
-
export interface XernerxMember extends GuildMember {
|
|
22
|
+
owner: boolean;
|
|
23
|
+
voter?: boolean;
|
|
31
24
|
}
|
|
25
|
+
export interface XernerxRole extends Role {}
|
|
26
|
+
export interface XernerxTextChannel extends TextChannel {}
|
|
27
|
+
export interface XernerxGuild extends Guild {}
|
|
28
|
+
export interface XernerxMember extends GuildMember {}
|
|
32
29
|
export type MessageCommandArgsTypes = 'rest' | 'option' | 'flag' | 'string' | 'number' | 'channel' | 'user' | 'member' | 'boolean' | 'role';
|
|
33
|
-
export type Localizations =
|
|
30
|
+
export type Localizations =
|
|
31
|
+
| 'id'
|
|
32
|
+
| 'da'
|
|
33
|
+
| 'de'
|
|
34
|
+
| 'en-GB'
|
|
35
|
+
| 'en-US'
|
|
36
|
+
| 'es-ES'
|
|
37
|
+
| 'fr'
|
|
38
|
+
| 'hr'
|
|
39
|
+
| 'it'
|
|
40
|
+
| 'lt'
|
|
41
|
+
| 'hu'
|
|
42
|
+
| 'nl'
|
|
43
|
+
| 'no'
|
|
44
|
+
| 'pl'
|
|
45
|
+
| 'pt-BR'
|
|
46
|
+
| 'ro'
|
|
47
|
+
| 'fi'
|
|
48
|
+
| 'sv-SE'
|
|
49
|
+
| 'vi'
|
|
50
|
+
| 'tr'
|
|
51
|
+
| 'cs'
|
|
52
|
+
| 'el'
|
|
53
|
+
| 'bg'
|
|
54
|
+
| 'ru'
|
|
55
|
+
| 'uk'
|
|
56
|
+
| 'hi'
|
|
57
|
+
| 'th'
|
|
58
|
+
| 'zh-CN'
|
|
59
|
+
| 'ja'
|
|
60
|
+
| 'zh-TW'
|
|
61
|
+
| 'ko';
|
|
34
62
|
export type EventEmitterType = 'client' | 'process';
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
+
exports.ClientUtil = void 0;
|
|
9
|
+
const XernerxError_js_1 = __importDefault(require('../tools/XernerxError.js'));
|
|
10
|
+
class ClientUtil {
|
|
3
11
|
client;
|
|
4
12
|
constructor(client) {
|
|
5
13
|
this.client = client;
|
|
6
14
|
}
|
|
7
15
|
uptime(timestamp) {
|
|
8
|
-
if (!timestamp)
|
|
9
|
-
timestamp = this.client.uptime || 0;
|
|
16
|
+
if (!timestamp) timestamp = this.client.uptime || 0;
|
|
10
17
|
let totalSeconds = timestamp / 1000;
|
|
11
18
|
let years = Math.floor(totalSeconds / 31536000);
|
|
12
19
|
totalSeconds %= 31536000;
|
|
@@ -16,90 +23,77 @@ export class ClientUtil {
|
|
|
16
23
|
totalSeconds %= 3600;
|
|
17
24
|
let minutes = Math.floor(totalSeconds / 60);
|
|
18
25
|
let seconds = Math.floor(totalSeconds % 60);
|
|
19
|
-
if (years >= 1)
|
|
20
|
-
|
|
21
|
-
else if (
|
|
22
|
-
|
|
23
|
-
else
|
|
24
|
-
return `${hours}h ${minutes}m`;
|
|
25
|
-
else if (minutes >= 1)
|
|
26
|
-
return `${minutes}m ${seconds}s`;
|
|
27
|
-
else
|
|
28
|
-
return `${seconds}s`;
|
|
26
|
+
if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;
|
|
27
|
+
else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
|
|
28
|
+
else if (hours >= 1) return `${hours}h ${minutes}m`;
|
|
29
|
+
else if (minutes >= 1) return `${minutes}m ${seconds}s`;
|
|
30
|
+
else return `${seconds}s`;
|
|
29
31
|
}
|
|
30
32
|
getSubcommands(name) {
|
|
31
|
-
if (!name || typeof name !== 'string')
|
|
32
|
-
throw new XernerxError(`Expected name to be of type string, received ${typeof name} instead!`);
|
|
33
|
+
if (!name || typeof name !== 'string') throw new XernerxError_js_1.default(`Expected name to be of type string, received ${typeof name} instead!`);
|
|
33
34
|
const commands = [];
|
|
34
35
|
this.getAllCommands()
|
|
35
36
|
.filter((c) => (c.data?.name?.toLowerCase() || c.name?.toLowerCase()) == name?.toLowerCase())
|
|
36
37
|
.map((c) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
if (c?.data?.options?.length > 0) {
|
|
39
|
+
c?.data?.options?.map((option) => {
|
|
40
|
+
if (!option?.type) {
|
|
41
|
+
if (option?.options?.length > 0) {
|
|
42
|
+
option?.options?.map((opt) => {
|
|
43
|
+
if (!opt.type) {
|
|
44
|
+
commands.push({
|
|
45
|
+
name: c.data.name,
|
|
46
|
+
formattedName: `${c.data.name} ${option.name} ${opt.name}`,
|
|
47
|
+
description: opt.description,
|
|
48
|
+
category: c.category || null,
|
|
49
|
+
commandType: c.commandType,
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
commands.push({
|
|
53
|
+
name: c.data.name,
|
|
54
|
+
formattedName: `${c.data.name} ${option.name}`,
|
|
55
|
+
description: option.description,
|
|
56
|
+
category: c.category || null,
|
|
57
|
+
commandType: c.commandType,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
commands.push({
|
|
63
|
+
name: c.data.name,
|
|
64
|
+
formattedName: `${c.data.name} ${option.name}`,
|
|
65
|
+
description: option.description,
|
|
66
|
+
category: c.category || null,
|
|
67
|
+
commandType: c.commandType,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
63
71
|
commands.push({
|
|
64
72
|
name: c.data.name,
|
|
65
|
-
formattedName: `${c.data.name}
|
|
66
|
-
description:
|
|
73
|
+
formattedName: `${c.data.name}`,
|
|
74
|
+
description: c.data.description,
|
|
67
75
|
category: c.category || null,
|
|
68
76
|
commandType: c.commandType,
|
|
69
77
|
});
|
|
70
78
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
commands.push({
|
|
85
|
-
name: c.data?.name || c.name,
|
|
86
|
-
formattedName: `${c.data?.name || c.name}`,
|
|
87
|
-
description: c.data?.description || c.description,
|
|
88
|
-
category: c.category || null,
|
|
89
|
-
commandType: c.commandType,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
commands.push({
|
|
82
|
+
name: c.data?.name || c.name,
|
|
83
|
+
formattedName: `${c.data?.name || c.name}`,
|
|
84
|
+
description: c.data?.description || c.description,
|
|
85
|
+
category: c.category || null,
|
|
86
|
+
commandType: c.commandType,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
93
90
|
return commands;
|
|
94
91
|
}
|
|
95
92
|
isOwner(userId) {
|
|
96
|
-
if (!userId)
|
|
97
|
-
throw new XernerxError('No ID specified');
|
|
93
|
+
if (!userId) throw new XernerxError_js_1.default('No ID specified');
|
|
98
94
|
let owners = this.client.settings.ownerId;
|
|
99
|
-
if (!owners)
|
|
100
|
-
|
|
101
|
-
if (typeof owners === 'string')
|
|
102
|
-
owners = [owners];
|
|
95
|
+
if (!owners) return false;
|
|
96
|
+
if (typeof owners === 'string') owners = [owners];
|
|
103
97
|
return owners.includes(userId);
|
|
104
98
|
}
|
|
105
99
|
getAllCommands() {
|
|
@@ -148,8 +142,7 @@ export class ClientUtil {
|
|
|
148
142
|
getCooldowns(id, command) {
|
|
149
143
|
let cooldowns = [];
|
|
150
144
|
for (const [key, value] of Object.entries(this.client.cache)) {
|
|
151
|
-
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
|
|
152
|
-
continue;
|
|
145
|
+
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
|
|
153
146
|
if (key === 'commands') {
|
|
154
147
|
if (command) {
|
|
155
148
|
value.map((x) => {
|
|
@@ -159,16 +152,14 @@ export class ClientUtil {
|
|
|
159
152
|
cooldowns.push(x);
|
|
160
153
|
}
|
|
161
154
|
});
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
155
|
+
} else {
|
|
164
156
|
value.map((x) => {
|
|
165
157
|
if (x.name.split(/-/).shift() === id) {
|
|
166
158
|
cooldowns.push(x);
|
|
167
159
|
}
|
|
168
160
|
});
|
|
169
161
|
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
162
|
+
} else {
|
|
172
163
|
if (value.has(id)) {
|
|
173
164
|
const x = value.get(id);
|
|
174
165
|
cooldowns.push(x);
|
|
@@ -180,8 +171,7 @@ export class ClientUtil {
|
|
|
180
171
|
getCooldownTimers(id, command) {
|
|
181
172
|
let cooldowns = [];
|
|
182
173
|
for (const [key, value] of Object.entries(this.client.cache)) {
|
|
183
|
-
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key))
|
|
184
|
-
continue;
|
|
174
|
+
if (!['cooldowns', 'messageCommands', 'slashCommands', 'contextCommands', 'commands'].includes(key)) continue;
|
|
185
175
|
if (key === 'commands') {
|
|
186
176
|
if (command) {
|
|
187
177
|
value.map((x) => {
|
|
@@ -193,8 +183,7 @@ export class ClientUtil {
|
|
|
193
183
|
});
|
|
194
184
|
}
|
|
195
185
|
});
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
186
|
+
} else {
|
|
198
187
|
value.map((x) => {
|
|
199
188
|
if (x.name.split(/-/).shift() === id) {
|
|
200
189
|
cooldowns.push({
|
|
@@ -203,8 +192,7 @@ export class ClientUtil {
|
|
|
203
192
|
}
|
|
204
193
|
});
|
|
205
194
|
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
195
|
+
} else {
|
|
208
196
|
if (value.has(id)) {
|
|
209
197
|
const x = value.get(id);
|
|
210
198
|
cooldowns.push({ [key]: x.endsAt - Date.now() });
|
|
@@ -220,3 +208,4 @@ export class ClientUtil {
|
|
|
220
208
|
return new Promise((resolve) => setTimeout(resolve, time || 0));
|
|
221
209
|
}
|
|
222
210
|
}
|
|
211
|
+
exports.ClientUtil = ClientUtil;
|
|
@@ -31,7 +31,7 @@ export declare class MessageCommandUtil {
|
|
|
31
31
|
reply(content: MessagePayload | string): Promise<Message<boolean> | undefined>;
|
|
32
32
|
send(content: MessagePayload | string): Promise<Message<true> | Message<false> | undefined>;
|
|
33
33
|
defer(time: number): Promise<unknown>;
|
|
34
|
-
getCommands(): import(
|
|
34
|
+
getCommands(): import('@discordjs/collection').Collection<string, import('../main.js').MessageCommandBuilder>;
|
|
35
35
|
getCommandName(): void;
|
|
36
36
|
selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
|
|
37
37
|
buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
|
|
@@ -45,7 +45,9 @@ export declare class InteractionCommandUtil {
|
|
|
45
45
|
constructor(client: XernerxClient, interaction: Interaction);
|
|
46
46
|
reply(content: MessagePayload | string): any;
|
|
47
47
|
defer(time: number): Promise<unknown>;
|
|
48
|
-
getCommands():
|
|
48
|
+
getCommands():
|
|
49
|
+
| import('@discordjs/collection').Collection<string, import('../main.js').SlashCommandBuilder>
|
|
50
|
+
| import('@discordjs/collection').Collection<string, import('../main.js').ContextCommandBuilder>;
|
|
49
51
|
getCommandName(): void;
|
|
50
52
|
selectMenuPaginator(embeds: Array<EmbedBuilder>, options?: SelectMenuOptions): void;
|
|
51
53
|
buttonPaginator(embeds: Array<EmbedBuilder>, options: ButtonOptions): void;
|