xernerx 4.17.9 → 5.0.2
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/README.md +14 -67
- package/dist/main.cjs +63 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.d.cts +21 -0
- package/dist/main.d.ts +18 -37
- package/dist/main.js +23 -42
- package/dist/main.js.map +1 -0
- package/package.json +63 -48
- package/src/main.ts +26 -0
- package/dist/build/XernerxContextCommand.d.ts +0 -54
- package/dist/build/XernerxContextCommand.js +0 -121
- package/dist/build/XernerxEvent.d.ts +0 -21
- package/dist/build/XernerxEvent.js +0 -27
- package/dist/build/XernerxInhibitor.d.ts +0 -29
- package/dist/build/XernerxInhibitor.js +0 -27
- package/dist/build/XernerxMessageCommand.d.ts +0 -58
- package/dist/build/XernerxMessageCommand.js +0 -119
- package/dist/build/XernerxSlashCommand.d.ts +0 -70
- package/dist/build/XernerxSlashCommand.js +0 -178
- package/dist/client/XernerxClient.d.ts +0 -64
- package/dist/client/XernerxClient.js +0 -109
- package/dist/client/XernerxShardClient.d.ts +0 -21
- package/dist/client/XernerxShardClient.js +0 -54
- package/dist/functions/deploy.d.ts +0 -3
- package/dist/functions/deploy.js +0 -63
- package/dist/functions/load.d.ts +0 -4
- package/dist/functions/load.js +0 -35
- package/dist/functions/reload.d.ts +0 -3
- package/dist/functions/reload.js +0 -30
- package/dist/functions/setPresence.d.ts +0 -4
- package/dist/functions/setPresence.js +0 -21
- package/dist/handlers/CommandHandler.d.ts +0 -16
- package/dist/handlers/CommandHandler.js +0 -351
- package/dist/handlers/EventHandler.d.ts +0 -11
- package/dist/handlers/EventHandler.js +0 -84
- package/dist/handlers/ExtensionHandler.d.ts +0 -9
- package/dist/handlers/ExtensionHandler.js +0 -29
- package/dist/handlers/Handler.d.ts +0 -26
- package/dist/handlers/Handler.js +0 -64
- package/dist/handlers/InhibitorHandler.d.ts +0 -9
- package/dist/handlers/InhibitorHandler.js +0 -31
- package/dist/handlers/IntegrationHandler.d.ts +0 -15
- package/dist/handlers/IntegrationHandler.js +0 -26
- package/dist/models/Arguments.d.ts +0 -9
- package/dist/models/Arguments.js +0 -154
- package/dist/models/Cooldowns.d.ts +0 -11
- package/dist/models/Cooldowns.js +0 -33
- package/dist/models/XernerxEntitlement.d.ts +0 -45
- package/dist/models/XernerxEntitlement.js +0 -57
- package/dist/models/XernerxUser.d.ts +0 -14
- package/dist/models/XernerxUser.js +0 -13
- package/dist/tools/XernerxError.d.ts +0 -7
- package/dist/tools/XernerxError.js +0 -11
- package/dist/tools/XernerxIntents.d.ts +0 -6
- package/dist/tools/XernerxIntents.js +0 -26
- package/dist/tools/XernerxLog.d.ts +0 -31
- package/dist/tools/XernerxLog.js +0 -139
- package/dist/tools/XernerxText.d.ts +0 -31
- package/dist/tools/XernerxText.js +0 -94
- package/dist/types/extenders.d.ts +0 -76
- package/dist/types/extenders.js +0 -2
- package/dist/types/interfaces.d.ts +0 -258
- package/dist/types/interfaces.js +0 -2
- package/dist/types/types.d.ts +0 -12
- package/dist/types/types.js +0 -2
- package/dist/utils/ClientUtil.d.ts +0 -20
- package/dist/utils/ClientUtil.js +0 -123
- package/dist/utils/InteractionUtil.d.ts +0 -25
- package/dist/utils/InteractionUtil.js +0 -153
- package/dist/utils/MessageUtil.d.ts +0 -26
- package/dist/utils/MessageUtil.js +0 -167
- package/dist/utils/Util.d.ts +0 -12
- package/dist/utils/Util.js +0 -11
- package/dist/validators/commandValidation.d.ts +0 -7
- package/dist/validators/commandValidation.js +0 -124
- package/dist/validators/inhibitorValidations.d.ts +0 -9
- package/dist/validators/inhibitorValidations.js +0 -44
- package/tsup.config.ts +0 -19
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { XernerxEventOptions } from '../types/interfaces.js';
|
|
3
|
-
import { XernerxClientEvents, XernerxClientType } from '../types/extenders.js';
|
|
4
|
-
import { Awaitable, RestEvents } from 'discord.js';
|
|
5
|
-
/**
|
|
6
|
-
* @description - The event builder for events.
|
|
7
|
-
* @param {String} id - The unique ID of the event.
|
|
8
|
-
* @param {EventOptions} options - The event options.
|
|
9
|
-
*/
|
|
10
|
-
export default class XernerxEvent<Event extends keyof XernerxClientEvents> {
|
|
11
|
-
readonly id: string;
|
|
12
|
-
readonly name: Event | keyof RestEvents | string;
|
|
13
|
-
readonly emitter?: 'client' | 'process' | 'rest' | string;
|
|
14
|
-
readonly type?: 'discord' | 'node' | string;
|
|
15
|
-
readonly once?: boolean;
|
|
16
|
-
readonly filetype: 'Event';
|
|
17
|
-
readonly filepath: string;
|
|
18
|
-
readonly client: XernerxClientType;
|
|
19
|
-
constructor(id: string, options: XernerxEventOptions);
|
|
20
|
-
run<T = void>(...args: XernerxClientEvents[Event]): Promise<Awaitable<void | any | T>>;
|
|
21
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
4
|
-
/**
|
|
5
|
-
* @description - The event builder for events.
|
|
6
|
-
* @param {String} id - The unique ID of the event.
|
|
7
|
-
* @param {EventOptions} options - The event options.
|
|
8
|
-
*/
|
|
9
|
-
export default class XernerxEvent {
|
|
10
|
-
constructor(id, options) {
|
|
11
|
-
this.id = id;
|
|
12
|
-
z.object({
|
|
13
|
-
name: z.string(),
|
|
14
|
-
emitter: z.string().optional(),
|
|
15
|
-
type: z.string().optional(),
|
|
16
|
-
once: z.boolean().optional(),
|
|
17
|
-
}).parse(options);
|
|
18
|
-
this.name = options.name;
|
|
19
|
-
this.emitter = options.emitter || 'client';
|
|
20
|
-
this.type = options.type || 'discord';
|
|
21
|
-
this.once = options.once || false;
|
|
22
|
-
this.client = this.client;
|
|
23
|
-
}
|
|
24
|
-
async run(...args) {
|
|
25
|
-
return new XernerxLog(this.client).error(`${this.id} doesn't have a run rule.`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { XernerxInhibitorOptions, MessageCommandArguments, SlashCommandArguments, ContextCommandArguments } from '../types/interfaces.js';
|
|
3
|
-
import { InhibitorType, XernerxInteraction } from '../types/types.js';
|
|
4
|
-
import { XernerxClientType, XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
5
|
-
import XernerxContextCommand from '../build/XernerxContextCommand.js';
|
|
6
|
-
import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
|
|
7
|
-
import XernerxMessageCommand from '../build/XernerxMessageCommand.js';
|
|
8
|
-
/**
|
|
9
|
-
* @description - The inhibitor builder for inhibitors.
|
|
10
|
-
* @param {String} id - The unique ID of the inhibitor.
|
|
11
|
-
* @param {InhibitorOptions} options - The inhibitor options.
|
|
12
|
-
*/
|
|
13
|
-
export default class XernerxInhibitor {
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly name: string;
|
|
16
|
-
readonly type: InhibitorType;
|
|
17
|
-
readonly filetype: 'Inhibitor';
|
|
18
|
-
readonly filepath: string;
|
|
19
|
-
readonly client: XernerxClientType;
|
|
20
|
-
constructor(id: string, options: XernerxInhibitorOptions);
|
|
21
|
-
pre(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: any): void;
|
|
22
|
-
/**
|
|
23
|
-
* @description The check rule
|
|
24
|
-
* @param interaction - The interaction with the inhibitor, can be message and interaction
|
|
25
|
-
* @param args - The arguments parsed with this command
|
|
26
|
-
*/
|
|
27
|
-
check<T extends XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>>(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: (T extends XernerxMessage ? MessageCommandArguments : T extends XernerxSlashInteraction ? SlashCommandArguments : T extends XernerxUserContextInteraction ? ContextCommandArguments<'user' | 'message'> : never) | null, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand): Promise<any>;
|
|
28
|
-
post<T extends XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>>(interaction: XernerxMessage | XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, args: (T extends XernerxMessage ? MessageCommandArguments : T extends XernerxSlashInteraction ? SlashCommandArguments : T extends XernerxUserContextInteraction ? ContextCommandArguments<'user' | 'message'> : never) | null, command: XernerxSlashCommand | XernerxMessageCommand | XernerxContextCommand): Promise<any>;
|
|
29
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/**
|
|
4
|
-
* @description - The inhibitor builder for inhibitors.
|
|
5
|
-
* @param {String} id - The unique ID of the inhibitor.
|
|
6
|
-
* @param {InhibitorOptions} options - The inhibitor options.
|
|
7
|
-
*/
|
|
8
|
-
export default class XernerxInhibitor {
|
|
9
|
-
constructor(id, options) {
|
|
10
|
-
this.id = id;
|
|
11
|
-
z.object({
|
|
12
|
-
name: z.string(),
|
|
13
|
-
type: z.string(),
|
|
14
|
-
}).parse(options);
|
|
15
|
-
this.name = options.name;
|
|
16
|
-
this.type = options.type;
|
|
17
|
-
this.client = this.client;
|
|
18
|
-
}
|
|
19
|
-
pre(interaction, args) { }
|
|
20
|
-
/**
|
|
21
|
-
* @description The check rule
|
|
22
|
-
* @param interaction - The interaction with the inhibitor, can be message and interaction
|
|
23
|
-
* @param args - The arguments parsed with this command
|
|
24
|
-
*/
|
|
25
|
-
async check(interaction, args, command) { }
|
|
26
|
-
async post(interaction, args, command) { }
|
|
27
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { XernerxClientType, XernerxMessage } from '../types/extenders.js';
|
|
3
|
-
import { MessageCommandArguments, MessageCommandOptions } from '../types/interfaces.js';
|
|
4
|
-
import MessageUtil from '../utils/MessageUtil.js';
|
|
5
|
-
export default class XernerxMessageCommand {
|
|
6
|
-
readonly id: string;
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly aliases: string[] | undefined;
|
|
9
|
-
readonly regex: RegExp | undefined;
|
|
10
|
-
readonly prefix: string | string[] | undefined;
|
|
11
|
-
readonly description: string | null | undefined;
|
|
12
|
-
readonly usage: string | null | undefined;
|
|
13
|
-
readonly info: string | null | undefined;
|
|
14
|
-
readonly separator: string | undefined;
|
|
15
|
-
readonly args: import("../types/interfaces.js").MessageCommandArgumentOptions[] | undefined;
|
|
16
|
-
readonly flags: import("../types/interfaces.js").MessageCommandFlagOptions[] | undefined;
|
|
17
|
-
readonly category: string | null | undefined;
|
|
18
|
-
readonly cooldown: number | null | undefined;
|
|
19
|
-
readonly channel: ("GuildText" | "DM" | "GuildVoice" | "GroupDM" | "GuildCategory" | "GuildAnnouncement" | "AnnouncementThread" | "PublicThread" | "PrivateThread" | "GuildStageVoice" | "GuildDirectory" | "GuildForum" | "GuildMedia" | "GuildNews" | "GuildNewsThread" | "GuildPublicThread" | "GuildPrivateThread")[] | null;
|
|
20
|
-
readonly global: boolean | undefined;
|
|
21
|
-
readonly ignore: {
|
|
22
|
-
owner?: boolean;
|
|
23
|
-
users?: Array<string>;
|
|
24
|
-
channels?: Array<string>;
|
|
25
|
-
guilds?: Array<string>;
|
|
26
|
-
voice?: boolean;
|
|
27
|
-
} | undefined;
|
|
28
|
-
readonly strict: {
|
|
29
|
-
owner?: boolean;
|
|
30
|
-
users?: Array<string>;
|
|
31
|
-
channels?: Array<string>;
|
|
32
|
-
guilds?: Array<string>;
|
|
33
|
-
voice?: boolean;
|
|
34
|
-
} | undefined;
|
|
35
|
-
readonly permissions: {
|
|
36
|
-
user?: Array<import("../main.js").PermissionNames> | Array<string> | null;
|
|
37
|
-
client?: Array<import("../main.js").PermissionNames> | Array<string> | null;
|
|
38
|
-
dm?: boolean;
|
|
39
|
-
} | undefined;
|
|
40
|
-
readonly filetype: 'MessageCommand';
|
|
41
|
-
readonly filepath: string;
|
|
42
|
-
readonly client: XernerxClientType;
|
|
43
|
-
snowflake: string | null;
|
|
44
|
-
util: MessageUtil;
|
|
45
|
-
constructor(id: string, options: MessageCommandOptions);
|
|
46
|
-
/**
|
|
47
|
-
* @description Checks for conditions before running the command
|
|
48
|
-
* @param message - The message event emitted on this command
|
|
49
|
-
* @param options - The args and flags parsed on this command
|
|
50
|
-
*/
|
|
51
|
-
conditions<T = void>(message: XernerxMessage, { args, flags }: MessageCommandArguments): Promise<void | any | T>;
|
|
52
|
-
/**
|
|
53
|
-
* @description Runs the execution rule
|
|
54
|
-
* @param message - The message event emitted on this command
|
|
55
|
-
* @param options - The args and flags parsed on this command
|
|
56
|
-
*/
|
|
57
|
-
exec<T = void>(message: XernerxMessage, { args, flags }: MessageCommandArguments): Promise<void | any | T>;
|
|
58
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
4
|
-
export default class XernerxMessageCommand {
|
|
5
|
-
constructor(id, options) {
|
|
6
|
-
this.id = id;
|
|
7
|
-
this.regex = options.regex;
|
|
8
|
-
this.args = options.args;
|
|
9
|
-
this.flags = options.flags;
|
|
10
|
-
options = z
|
|
11
|
-
.object({
|
|
12
|
-
name: z.string(),
|
|
13
|
-
aliases: z.array(z.string()).default([]),
|
|
14
|
-
description: z.string().or(z.null()).default(null),
|
|
15
|
-
usage: z.string().or(z.null()).default(null),
|
|
16
|
-
info: z.string().or(z.null()).default(null),
|
|
17
|
-
category: z.string().or(z.null()).default(null),
|
|
18
|
-
cooldown: z.number().or(z.null()).default(null),
|
|
19
|
-
global: z.boolean().default(true),
|
|
20
|
-
channel: z
|
|
21
|
-
.array(z.enum([
|
|
22
|
-
'GuildText',
|
|
23
|
-
'DM',
|
|
24
|
-
'GuildVoice',
|
|
25
|
-
'GroupDM',
|
|
26
|
-
'GuildCategory',
|
|
27
|
-
'GuildAnnouncement',
|
|
28
|
-
'AnnouncementThread',
|
|
29
|
-
'PublicThread',
|
|
30
|
-
'PrivateThread',
|
|
31
|
-
'GuildStageVoice',
|
|
32
|
-
'GuildDirectory',
|
|
33
|
-
'GuildForum',
|
|
34
|
-
'GuildNews',
|
|
35
|
-
'GuildNewsThread',
|
|
36
|
-
'GuildPublicThread',
|
|
37
|
-
'GuildPrivateThread',
|
|
38
|
-
]))
|
|
39
|
-
.or(z.enum([
|
|
40
|
-
'GuildText',
|
|
41
|
-
'DM',
|
|
42
|
-
'GuildVoice',
|
|
43
|
-
'GroupDM',
|
|
44
|
-
'GuildCategory',
|
|
45
|
-
'GuildAnnouncement',
|
|
46
|
-
'AnnouncementThread',
|
|
47
|
-
'PublicThread',
|
|
48
|
-
'PrivateThread',
|
|
49
|
-
'GuildStageVoice',
|
|
50
|
-
'GuildDirectory',
|
|
51
|
-
'GuildForum',
|
|
52
|
-
'GuildNews',
|
|
53
|
-
'GuildNewsThread',
|
|
54
|
-
'GuildPublicThread',
|
|
55
|
-
'GuildPrivateThread',
|
|
56
|
-
]))
|
|
57
|
-
.or(z.null())
|
|
58
|
-
.default(null),
|
|
59
|
-
prefix: z.array(z.string()).or(z.string()).default([]),
|
|
60
|
-
ignore: z
|
|
61
|
-
.object({
|
|
62
|
-
owner: z.boolean().default(false),
|
|
63
|
-
users: z.array(z.string()).default([]),
|
|
64
|
-
channels: z.array(z.string()).default([]),
|
|
65
|
-
guilds: z.array(z.string()).default([]),
|
|
66
|
-
voice: z.boolean().default(false),
|
|
67
|
-
})
|
|
68
|
-
.default({}),
|
|
69
|
-
strict: z
|
|
70
|
-
.object({
|
|
71
|
-
owner: z.boolean().default(false),
|
|
72
|
-
users: z.array(z.string()).default([]),
|
|
73
|
-
channels: z.array(z.string()).default([]),
|
|
74
|
-
guilds: z.array(z.string()).default([]),
|
|
75
|
-
voice: z.boolean().default(false),
|
|
76
|
-
})
|
|
77
|
-
.default({}),
|
|
78
|
-
permissions: z
|
|
79
|
-
.object({
|
|
80
|
-
user: z.array(z.string()).or(z.null()).default(null),
|
|
81
|
-
client: z.array(z.string()).or(z.null()).default(null),
|
|
82
|
-
dm: z.boolean().default(true),
|
|
83
|
-
})
|
|
84
|
-
.default({}),
|
|
85
|
-
})
|
|
86
|
-
.parse(options);
|
|
87
|
-
this.name = options.name;
|
|
88
|
-
this.aliases = options.aliases;
|
|
89
|
-
this.prefix = options.prefix;
|
|
90
|
-
this.description = options.description;
|
|
91
|
-
this.usage = options.usage;
|
|
92
|
-
this.info = options.info;
|
|
93
|
-
this.category = options.category;
|
|
94
|
-
this.cooldown = options.cooldown;
|
|
95
|
-
this.channel = options.channel ? (Array.isArray(options.channel) ? options.channel : [options.channel]) : null;
|
|
96
|
-
this.global = options.global;
|
|
97
|
-
this.ignore = options.ignore;
|
|
98
|
-
this.strict = options.strict;
|
|
99
|
-
this.separator = options.separator;
|
|
100
|
-
this.permissions = options.permissions;
|
|
101
|
-
this.client = this.client;
|
|
102
|
-
this.util = this.util;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* @description Checks for conditions before running the command
|
|
106
|
-
* @param message - The message event emitted on this command
|
|
107
|
-
* @param options - The args and flags parsed on this command
|
|
108
|
-
*/
|
|
109
|
-
async conditions(message, { args, flags }) { }
|
|
110
|
-
/**
|
|
111
|
-
* @description Runs the execution rule
|
|
112
|
-
* @param message - The message event emitted on this command
|
|
113
|
-
* @param options - The args and flags parsed on this command
|
|
114
|
-
*/
|
|
115
|
-
async exec(message, { args, flags }) {
|
|
116
|
-
new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
|
|
117
|
-
return await this.client.emit('commandError', message, `${this.id} doesn't have an execution rule.`, this);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { AutocompleteFocusedOption, AutocompleteInteraction, SlashCommandBuilder } from 'discord.js';
|
|
3
|
-
import { XernerxClientType, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
4
|
-
import { SlashCommandArguments, SlashCommandOptions } from '../types/interfaces.js';
|
|
5
|
-
import { XernerxInteraction } from '../types/types.js';
|
|
6
|
-
import InteractionUtil from '../utils/InteractionUtil.js';
|
|
7
|
-
export default class XernerxSlashCommand {
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly data: SlashCommandBuilder;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly description: string;
|
|
12
|
-
readonly usage: string | null | undefined;
|
|
13
|
-
readonly info: string | null | undefined;
|
|
14
|
-
readonly category: string | null | undefined;
|
|
15
|
-
readonly cooldown: number | null | undefined;
|
|
16
|
-
readonly channel: ("GuildText" | "DM" | "GuildVoice" | "GroupDM" | "GuildCategory" | "GuildAnnouncement" | "AnnouncementThread" | "PublicThread" | "PrivateThread" | "GuildStageVoice" | "GuildDirectory" | "GuildForum" | "GuildMedia" | "GuildNews" | "GuildNewsThread" | "GuildPublicThread" | "GuildPrivateThread")[] | null;
|
|
17
|
-
readonly global: boolean | undefined;
|
|
18
|
-
readonly ignore: {
|
|
19
|
-
owner?: boolean;
|
|
20
|
-
users?: Array<string>;
|
|
21
|
-
channels?: Array<string>;
|
|
22
|
-
guilds?: Array<string>;
|
|
23
|
-
voice?: boolean;
|
|
24
|
-
} | undefined;
|
|
25
|
-
readonly strict: {
|
|
26
|
-
owner?: boolean;
|
|
27
|
-
users?: Array<string>;
|
|
28
|
-
channels?: Array<string>;
|
|
29
|
-
guilds?: Array<string>;
|
|
30
|
-
voice?: boolean;
|
|
31
|
-
} | undefined;
|
|
32
|
-
readonly permissions: {
|
|
33
|
-
user?: Array<import("../types/types.js").PermissionNames> | Array<string> | null;
|
|
34
|
-
client?: Array<import("../types/types.js").PermissionNames> | Array<string> | null;
|
|
35
|
-
dm?: boolean;
|
|
36
|
-
} | undefined;
|
|
37
|
-
readonly defer: {
|
|
38
|
-
reply?: boolean;
|
|
39
|
-
ephemeral?: boolean;
|
|
40
|
-
fetchReply?: boolean;
|
|
41
|
-
} | undefined;
|
|
42
|
-
readonly filetype: 'SlashCommand';
|
|
43
|
-
readonly filepath: string;
|
|
44
|
-
readonly client: XernerxClientType;
|
|
45
|
-
snowflake: string | null;
|
|
46
|
-
util: InteractionUtil;
|
|
47
|
-
constructor(id: string, options: SlashCommandOptions);
|
|
48
|
-
/**
|
|
49
|
-
* @description autocomplete let's you add choices to string option arguments
|
|
50
|
-
* @param interaction - The interaction event emitted on this command
|
|
51
|
-
* @param focused - The command option that is in focus
|
|
52
|
-
* @param options - The full list of options on the command
|
|
53
|
-
*/
|
|
54
|
-
autocomplete<T = void>(interaction: AutocompleteInteraction, focused: AutocompleteFocusedOption, options: any[]): Promise<void | any | T>;
|
|
55
|
-
/**
|
|
56
|
-
* @description Checks for conditions before running the command
|
|
57
|
-
* @param interaction - The interaction event emitted on this command
|
|
58
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
59
|
-
*/
|
|
60
|
-
conditions<T = void>(interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, { args, subcommand, group }: SlashCommandArguments): Promise<void | any | T>;
|
|
61
|
-
/**
|
|
62
|
-
* @description Runs the execution rule
|
|
63
|
-
* @param interaction - The interaction event emitted on this command
|
|
64
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
65
|
-
*/
|
|
66
|
-
exec<T = void>(interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>, { args, subcommand, group }: SlashCommandArguments): Promise<void | any | T>;
|
|
67
|
-
private addArguments;
|
|
68
|
-
private addSubcommands;
|
|
69
|
-
private addSubcommandGroups;
|
|
70
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from 'discord.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
5
|
-
export default class XernerxSlashCommand {
|
|
6
|
-
constructor(id, options) {
|
|
7
|
-
this.id = id;
|
|
8
|
-
this.data = new SlashCommandBuilder();
|
|
9
|
-
this.data.setName(options.name);
|
|
10
|
-
this.data.setNameLocalizations(options.nameLocalizations || null);
|
|
11
|
-
this.data.setDescription(options.description);
|
|
12
|
-
this.data.setDescriptionLocalizations(options.descriptionLocalizations || null);
|
|
13
|
-
this.data.setDMPermission(options.permissions?.dm || null);
|
|
14
|
-
if (options.args && options?.args?.length > 0) {
|
|
15
|
-
this.addArguments(this.data, options.args);
|
|
16
|
-
}
|
|
17
|
-
if (options.subcommands && options?.subcommands?.length > 0) {
|
|
18
|
-
this.addSubcommands(this.data, options.subcommands);
|
|
19
|
-
}
|
|
20
|
-
if (options.groups && options?.groups?.length > 0) {
|
|
21
|
-
this.addSubcommandGroups(options.groups);
|
|
22
|
-
}
|
|
23
|
-
options = z
|
|
24
|
-
.object({
|
|
25
|
-
name: z.string(),
|
|
26
|
-
description: z.string(),
|
|
27
|
-
usage: z.string().or(z.null()).default(null),
|
|
28
|
-
info: z.string().or(z.null()).default(null),
|
|
29
|
-
category: z.string().or(z.null()).default(null),
|
|
30
|
-
cooldown: z.number().or(z.null()).default(null),
|
|
31
|
-
number: z.number().or(z.null()).default(null),
|
|
32
|
-
global: z.boolean().default(true),
|
|
33
|
-
channel: z
|
|
34
|
-
.array(z.enum([
|
|
35
|
-
'GuildText',
|
|
36
|
-
'DM',
|
|
37
|
-
'GuildVoice',
|
|
38
|
-
'GroupDM',
|
|
39
|
-
'GuildCategory',
|
|
40
|
-
'GuildAnnouncement',
|
|
41
|
-
'AnnouncementThread',
|
|
42
|
-
'PublicThread',
|
|
43
|
-
'PrivateThread',
|
|
44
|
-
'GuildStageVoice',
|
|
45
|
-
'GuildDirectory',
|
|
46
|
-
'GuildForum',
|
|
47
|
-
'GuildNews',
|
|
48
|
-
'GuildNewsThread',
|
|
49
|
-
'GuildPublicThread',
|
|
50
|
-
'GuildPrivateThread',
|
|
51
|
-
]))
|
|
52
|
-
.or(z.enum([
|
|
53
|
-
'GuildText',
|
|
54
|
-
'DM',
|
|
55
|
-
'GuildVoice',
|
|
56
|
-
'GroupDM',
|
|
57
|
-
'GuildCategory',
|
|
58
|
-
'GuildAnnouncement',
|
|
59
|
-
'AnnouncementThread',
|
|
60
|
-
'PublicThread',
|
|
61
|
-
'PrivateThread',
|
|
62
|
-
'GuildStageVoice',
|
|
63
|
-
'GuildDirectory',
|
|
64
|
-
'GuildForum',
|
|
65
|
-
'GuildNews',
|
|
66
|
-
'GuildNewsThread',
|
|
67
|
-
'GuildPublicThread',
|
|
68
|
-
'GuildPrivateThread',
|
|
69
|
-
]))
|
|
70
|
-
.or(z.null())
|
|
71
|
-
.default(null),
|
|
72
|
-
ignore: z
|
|
73
|
-
.object({
|
|
74
|
-
owner: z.boolean().default(false),
|
|
75
|
-
users: z.array(z.string()).default([]),
|
|
76
|
-
channels: z.array(z.string()).default([]),
|
|
77
|
-
guilds: z.array(z.string()).default([]),
|
|
78
|
-
voice: z.boolean().default(false),
|
|
79
|
-
})
|
|
80
|
-
.default({}),
|
|
81
|
-
strict: z
|
|
82
|
-
.object({
|
|
83
|
-
owner: z.boolean().default(false),
|
|
84
|
-
users: z.array(z.string()).default([]),
|
|
85
|
-
channels: z.array(z.string()).default([]),
|
|
86
|
-
guilds: z.array(z.string()).default([]),
|
|
87
|
-
voice: z.boolean().default(false),
|
|
88
|
-
})
|
|
89
|
-
.default({}),
|
|
90
|
-
permissions: z
|
|
91
|
-
.object({
|
|
92
|
-
user: z.array(z.string()).or(z.null()).default(null),
|
|
93
|
-
client: z.array(z.string()).or(z.null()).default(null),
|
|
94
|
-
dm: z.boolean().default(true),
|
|
95
|
-
})
|
|
96
|
-
.default({}),
|
|
97
|
-
defer: z
|
|
98
|
-
.object({
|
|
99
|
-
reply: z.boolean().optional(),
|
|
100
|
-
ephemeral: z.boolean().optional(),
|
|
101
|
-
fetch: z.boolean().optional(),
|
|
102
|
-
})
|
|
103
|
-
.default({}),
|
|
104
|
-
})
|
|
105
|
-
.parse(options);
|
|
106
|
-
this.name = options.name;
|
|
107
|
-
this.description = options.description;
|
|
108
|
-
this.usage = options.usage;
|
|
109
|
-
this.info = options.info;
|
|
110
|
-
this.category = options.category;
|
|
111
|
-
this.cooldown = options.cooldown;
|
|
112
|
-
this.channel = options.channel ? (Array.isArray(options.channel) ? options.channel : [options.channel]) : null;
|
|
113
|
-
this.global = options.global;
|
|
114
|
-
this.ignore = options.ignore;
|
|
115
|
-
this.strict = options.strict;
|
|
116
|
-
this.permissions = options.permissions;
|
|
117
|
-
this.defer = options.defer;
|
|
118
|
-
this.client = this.client;
|
|
119
|
-
this.util = this.util;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @description autocomplete let's you add choices to string option arguments
|
|
123
|
-
* @param interaction - The interaction event emitted on this command
|
|
124
|
-
* @param focused - The command option that is in focus
|
|
125
|
-
* @param options - The full list of options on the command
|
|
126
|
-
*/
|
|
127
|
-
async autocomplete(interaction, focused, options) { }
|
|
128
|
-
/**
|
|
129
|
-
* @description Checks for conditions before running the command
|
|
130
|
-
* @param interaction - The interaction event emitted on this command
|
|
131
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
132
|
-
*/
|
|
133
|
-
async conditions(interaction, { args, subcommand, group }) { }
|
|
134
|
-
/**
|
|
135
|
-
* @description Runs the execution rule
|
|
136
|
-
* @param interaction - The interaction event emitted on this command
|
|
137
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
138
|
-
*/
|
|
139
|
-
async exec(interaction, { args, subcommand, group }) {
|
|
140
|
-
new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
|
|
141
|
-
return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this);
|
|
142
|
-
}
|
|
143
|
-
addArguments(command, args) {
|
|
144
|
-
for (const argument of args) {
|
|
145
|
-
let slashCommandArgumentType = `${argument.type.charAt(0).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
|
|
146
|
-
command[`add${slashCommandArgumentType}Option`]((option) => {
|
|
147
|
-
option
|
|
148
|
-
.setName(argument.name)
|
|
149
|
-
.setDescription(argument.description)
|
|
150
|
-
.setRequired(argument.required || false);
|
|
151
|
-
if (slashCommandArgumentType === 'String') {
|
|
152
|
-
if (argument.choices)
|
|
153
|
-
option.setChoices(...argument.choices.map((choices) => {
|
|
154
|
-
return { name: Object.keys(choices).at(0), value: Object.values(choices).at(0) };
|
|
155
|
-
}));
|
|
156
|
-
option.setAutocomplete(argument.autocomplete || false);
|
|
157
|
-
}
|
|
158
|
-
return option;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
addSubcommands(method, subcommands) {
|
|
163
|
-
for (const subcommand of subcommands) {
|
|
164
|
-
let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
|
|
165
|
-
if (subcommand.args && subcommand?.args?.length > 0)
|
|
166
|
-
this.addArguments(sub, subcommand.args);
|
|
167
|
-
method.addSubcommand(sub);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
addSubcommandGroups(groups) {
|
|
171
|
-
for (const group of groups) {
|
|
172
|
-
let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
|
|
173
|
-
if (group.subcommands?.length > 0)
|
|
174
|
-
this.addSubcommands(subcommandGroup, group.subcommands);
|
|
175
|
-
this.data.addSubcommandGroup(subcommandGroup);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Client, ClientOptions, Collection } from 'discord.js';
|
|
3
|
-
import { XernerxOptions, ModuleOptions, XernerxCommands, XernerxCache } from '../types/interfaces.js';
|
|
4
|
-
import { XernerxClientEvents } from '../types/extenders.js';
|
|
5
|
-
import ClientUtil from '../utils/ClientUtil.js';
|
|
6
|
-
import XernerxInhibitor from '../build/XernerxInhibitor.js';
|
|
7
|
-
import XernerxEvent from '../build/XernerxEvent.js';
|
|
8
|
-
import Cooldowns from '../models/Cooldowns.js';
|
|
9
|
-
export default class XernerxClient<T extends object = {
|
|
10
|
-
[index: string | number]: any;
|
|
11
|
-
}> extends Client {
|
|
12
|
-
readonly settings: {
|
|
13
|
-
ownerId: string | string[];
|
|
14
|
-
local: string;
|
|
15
|
-
ceaseless: boolean;
|
|
16
|
-
debug?: boolean | undefined;
|
|
17
|
-
permissions?: {
|
|
18
|
-
user: string[] | null;
|
|
19
|
-
client: string[] | null;
|
|
20
|
-
dm: boolean;
|
|
21
|
-
} | undefined;
|
|
22
|
-
global?: boolean | undefined;
|
|
23
|
-
ignore?: {
|
|
24
|
-
system: boolean;
|
|
25
|
-
users: string[];
|
|
26
|
-
channels: string[];
|
|
27
|
-
owner: boolean;
|
|
28
|
-
self: boolean;
|
|
29
|
-
bots: boolean;
|
|
30
|
-
guilds: string[];
|
|
31
|
-
} | undefined;
|
|
32
|
-
log?: boolean | {
|
|
33
|
-
warn: boolean;
|
|
34
|
-
error: boolean;
|
|
35
|
-
ready: boolean;
|
|
36
|
-
info: boolean;
|
|
37
|
-
table: string[] | null;
|
|
38
|
-
format: string[] | null;
|
|
39
|
-
} | undefined;
|
|
40
|
-
cooldown?: {
|
|
41
|
-
command: number;
|
|
42
|
-
cache: number;
|
|
43
|
-
collections: string[];
|
|
44
|
-
} | undefined;
|
|
45
|
-
};
|
|
46
|
-
readonly config: T;
|
|
47
|
-
readonly commands: XernerxCommands;
|
|
48
|
-
readonly events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
|
|
49
|
-
readonly inhibitors: Collection<string, XernerxInhibitor>;
|
|
50
|
-
readonly modules: ModuleOptions;
|
|
51
|
-
readonly util: ClientUtil;
|
|
52
|
-
readonly stats: Record<string, number>;
|
|
53
|
-
readonly cache: XernerxCache;
|
|
54
|
-
readonly cooldowns: Cooldowns;
|
|
55
|
-
store: {
|
|
56
|
-
front?: any;
|
|
57
|
-
archive?: any;
|
|
58
|
-
items?: any;
|
|
59
|
-
};
|
|
60
|
-
readonly dbl: any;
|
|
61
|
-
readonly [index: string]: unknown;
|
|
62
|
-
constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: T);
|
|
63
|
-
connect(token: string): Promise<string | void>;
|
|
64
|
-
}
|