xernerx 3.2.6 → 3.3.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/ContextCommand.d.ts +1 -1
- package/dist/build/ContextCommand.js +1 -1
- package/dist/build/ContextCommandBuilder.d.ts +40 -0
- package/dist/build/ContextCommandBuilder.js +84 -0
- package/dist/build/Event.d.ts +1 -1
- package/dist/build/Event.js +1 -1
- package/dist/build/EventBuilder.d.ts +17 -0
- package/dist/build/EventBuilder.js +35 -0
- package/dist/build/ExtensionBuilder.d.ts +7 -0
- package/dist/build/ExtensionBuilder.js +9 -0
- package/dist/build/Inhibitor.d.ts +3 -0
- package/dist/build/Inhibitor.js +3 -0
- package/dist/build/InhibitorBuilder.d.ts +19 -0
- package/dist/build/InhibitorBuilder.js +28 -0
- package/dist/build/MessageCommand.d.ts +2 -2
- package/dist/build/MessageCommand.js +1 -1
- package/dist/build/MessageCommandBuilder.d.ts +42 -0
- package/dist/build/MessageCommandBuilder.js +80 -0
- package/dist/build/SlashCommand.d.ts +3 -3
- package/dist/build/SlashCommand.js +3 -3
- package/dist/build/SlashCommandBuilder.d.ts +36 -0
- package/dist/build/SlashCommandBuilder.js +125 -0
- package/dist/build/XernerxExtension.d.ts +7 -0
- package/dist/build/XernerxExtension.js +9 -0
- package/dist/client/XernerxClient.d.ts +11 -7
- package/dist/client/XernerxClient.js +0 -2
- package/dist/handlers/CommandHandler.d.ts +4 -4
- package/dist/handlers/EventHandler.d.ts +2 -2
- package/dist/handlers/Handler.d.ts +6 -6
- package/dist/handlers/Handler.js +1 -1
- package/dist/handlers/InhibitorHandler.d.ts +2 -2
- package/dist/interfaces/ClientInterfaces.d.ts +8 -7
- package/dist/interfaces/CommandInterfaces.d.ts +1 -1
- package/dist/interfaces/HandlerInterfaces.d.ts +2 -11
- package/dist/main.d.ts +14 -13
- package/dist/main.js +16 -15
- package/dist/models/CommandArguments.d.ts +15 -7
- package/dist/models/CommandArguments.js +27 -33
- package/dist/models/CommandValidations.d.ts +4 -3
- package/dist/models/CommandValidations.js +9 -17
- package/dist/models/Events.d.ts +1 -0
- package/dist/models/Events.js +61 -140
- package/dist/models/Extensions.d.ts +2 -2
- package/dist/models/InhibitorValidations.d.ts +8 -13
- package/dist/models/InhibitorValidations.js +1 -1
- package/dist/types/Types.d.ts +29 -25
- package/dist/types/Types.js +1 -26
- package/dist/types/enums.d.ts +35 -0
- package/dist/types/enums.js +35 -0
- package/dist/types/interfaces.d.ts +25 -0
- package/dist/types/interfaces.js +1 -0
- package/dist/types/objects.d.ts +18 -0
- package/dist/types/objects.js +1 -0
- package/dist/types/options.d.ts +204 -0
- package/dist/types/options.js +1 -0
- package/dist/utils/ClientUtil.js +1 -2
- package/dist/utils/CommandUtil.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Client, Collection } from "discord.js";
|
|
2
2
|
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ClientOptions, DiscordOptions, ExtensionOptions, HandlerOptions } from "../types/options.js";
|
|
4
|
+
import { ClientCache, ClientCommands, ClientModules } from "../types/interfaces.js";
|
|
5
|
+
import EventBuilder from "../build/EventBuilder.js";
|
|
6
|
+
import ExtensionBuilder from "../build/ExtensionBuilder.js";
|
|
7
|
+
import InhibitorBuilder from "../build/InhibitorBuilder.js";
|
|
4
8
|
/**
|
|
5
9
|
* @description - The Client.
|
|
6
10
|
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
@@ -9,14 +13,14 @@ import { DiscordOptions, ClientOptions, Commands, Cache, Modules, HandlerOptions
|
|
|
9
13
|
*/
|
|
10
14
|
export default class XernerxClient extends Client {
|
|
11
15
|
settings: ClientOptions;
|
|
12
|
-
commands:
|
|
13
|
-
cache:
|
|
14
|
-
modules:
|
|
16
|
+
commands: ClientCommands;
|
|
17
|
+
cache: ClientCache;
|
|
18
|
+
modules: ClientModules;
|
|
15
19
|
util: ClientUtil;
|
|
16
20
|
handlerOptions: HandlerOptions;
|
|
17
|
-
events: Collection<string,
|
|
18
|
-
extensions: Record<string,
|
|
19
|
-
inhibitors: Collection<string,
|
|
21
|
+
events: Collection<string, EventBuilder>;
|
|
22
|
+
extensions: Record<string, ExtensionBuilder>;
|
|
23
|
+
inhibitors: Collection<string, InhibitorBuilder>;
|
|
20
24
|
config: object;
|
|
21
25
|
constructor(discordOptions: DiscordOptions, clientOptions: ClientOptions, config?: object);
|
|
22
26
|
register(token: string): void;
|
|
@@ -5,7 +5,6 @@ import EventHandler from "../handlers/EventHandler.js";
|
|
|
5
5
|
import InhibitorHandler from "../handlers/InhibitorHandler.js";
|
|
6
6
|
import { ClientUtil } from "../utils/ClientUtil.js";
|
|
7
7
|
import { Style } from "dumfunctions";
|
|
8
|
-
import WebhookHandler from "../handlers/WebhookHandler.js";
|
|
9
8
|
import Extensions from "../models/Extensions.js";
|
|
10
9
|
/**
|
|
11
10
|
* @description - The Client.
|
|
@@ -59,7 +58,6 @@ export default class XernerxClient extends Client {
|
|
|
59
58
|
commandHandler: new CommandHandler(this),
|
|
60
59
|
eventHandler: new EventHandler(this),
|
|
61
60
|
inhibitorHandler: new InhibitorHandler(this),
|
|
62
|
-
webhookHandler: new WebhookHandler(this),
|
|
63
61
|
};
|
|
64
62
|
this.extensions = {};
|
|
65
63
|
this.util = new ClientUtil(this);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ContextCommandOptions, SlashCommandOptions, MessageCommandOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
1
|
import XernerxClient from "../client/XernerxClient.js";
|
|
3
2
|
import { Handler } from "./Handler.js";
|
|
3
|
+
import { ContextCommandHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from "../types/options.js";
|
|
4
4
|
/**
|
|
5
5
|
* @description - The command handler.
|
|
6
6
|
* @param {XernerxClient} client - The XernerxClient.
|
|
@@ -13,15 +13,15 @@ export default class CommandHandler {
|
|
|
13
13
|
* @description - The message command loader.
|
|
14
14
|
* @param {MessageCommandOptions} options - message command loader options.
|
|
15
15
|
*/
|
|
16
|
-
loadAllMessageCommands(options:
|
|
16
|
+
loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
|
|
17
17
|
/**
|
|
18
18
|
* @description - The slash command loader.
|
|
19
19
|
* @param {SlashCommandOptions} options - slash command loader options.
|
|
20
20
|
*/
|
|
21
|
-
loadAllSlashCommands(options:
|
|
21
|
+
loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
|
|
22
22
|
/**
|
|
23
23
|
* @description - The context command loader.
|
|
24
24
|
* @param {ContextCommandOptions} options - context command loader options.
|
|
25
25
|
*/
|
|
26
|
-
loadAllContextCommands(options:
|
|
26
|
+
loadAllContextCommands(options: ContextCommandHandlerOptions): void;
|
|
27
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EventLoadOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
1
|
import XernerxClient from "../client/XernerxClient.js";
|
|
2
|
+
import { EventHandlerOptions } from "../types/options.js";
|
|
3
3
|
import { Handler } from "./Handler.js";
|
|
4
4
|
export default class EventHandler {
|
|
5
5
|
client: XernerxClient;
|
|
@@ -9,5 +9,5 @@ export default class EventHandler {
|
|
|
9
9
|
* @description - The event loader
|
|
10
10
|
* @param {EventLoadOptions} options - message command options
|
|
11
11
|
*/
|
|
12
|
-
loadAllEvents(options:
|
|
12
|
+
loadAllEvents(options: EventHandlerOptions): void;
|
|
13
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import XernerxClient from "../client/XernerxClient.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ContextCommandHandlerOptions, EventHandlerOptions, InhibitorHandlerOptions, MessageCommandHandlerOptions, SlashCommandHandlerOptions } from "../types/options.js";
|
|
3
3
|
/**
|
|
4
4
|
* @description - The Handler class.
|
|
5
5
|
* @param {XernerxClient} client - The XernerxClient.
|
|
@@ -14,25 +14,25 @@ export declare class Handler {
|
|
|
14
14
|
* @description - The loader for the message commands.
|
|
15
15
|
* @param {MessageCommandOptions} options - The options for the message command loader.
|
|
16
16
|
*/
|
|
17
|
-
loadAllMessageCommands(options:
|
|
17
|
+
loadAllMessageCommands(options: MessageCommandHandlerOptions): void;
|
|
18
18
|
/**
|
|
19
19
|
* @description - The loader for the slash commands.
|
|
20
20
|
* @param {SlashCommandOptions} options - The options for the slash command loader.
|
|
21
21
|
*/
|
|
22
|
-
loadAllSlashCommands(options:
|
|
22
|
+
loadAllSlashCommands(options: SlashCommandHandlerOptions): void;
|
|
23
23
|
/**
|
|
24
24
|
* @description - The loader for the context commands.
|
|
25
25
|
* @param {ContextCommandOptions} options - The options for the context command loader.
|
|
26
26
|
*/
|
|
27
|
-
loadAllContextCommands(options:
|
|
27
|
+
loadAllContextCommands(options: ContextCommandHandlerOptions): void;
|
|
28
28
|
/**
|
|
29
29
|
* @description - The loader for the events.
|
|
30
30
|
* @param {EventLoadOptions} options - The options for the event loader.
|
|
31
31
|
*/
|
|
32
|
-
loadAllEvents(options:
|
|
32
|
+
loadAllEvents(options: EventHandlerOptions): void;
|
|
33
33
|
/**
|
|
34
34
|
* @description - The loader for the inhibitors.
|
|
35
35
|
* @param {InhibitorLoadOptions} options - The options for the inhibitor loader.
|
|
36
36
|
*/
|
|
37
|
-
loadAllInhibitors(options:
|
|
37
|
+
loadAllInhibitors(options: InhibitorHandlerOptions): void;
|
|
38
38
|
}
|
package/dist/handlers/Handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InhibitorLoadOptions } from "../interfaces/HandlerInterfaces.js";
|
|
2
1
|
import XernerxClient from "../client/XernerxClient.js";
|
|
2
|
+
import { InhibitorHandlerOptions } from "../types/options.js";
|
|
3
3
|
import { Handler } from "./Handler.js";
|
|
4
4
|
/**
|
|
5
5
|
* @description - Inhibitor loader.
|
|
@@ -14,5 +14,5 @@ export default class InhibitorHandler {
|
|
|
14
14
|
* @param {InhibitorLoadOptions} options - the inhibitor loader options.
|
|
15
15
|
* @returns undefined
|
|
16
16
|
*/
|
|
17
|
-
loadAllInhibitors(options:
|
|
17
|
+
loadAllInhibitors(options: InhibitorHandlerOptions): void;
|
|
18
18
|
}
|
|
@@ -3,8 +3,10 @@ import CommandHandler from "../handlers/CommandHandler.js";
|
|
|
3
3
|
import EventHandler from "../handlers/EventHandler.js";
|
|
4
4
|
import InhibitorHandler from "../handlers/InhibitorHandler.js";
|
|
5
5
|
import { ContextCommandOptions, MessageCommandOptions, SlashCommandOptions, EventLoadOptions, InhibitorLoadOptions } from "./HandlerInterfaces.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import MessageCommandBuilder from "../build/MessageCommandBuilder.js";
|
|
7
|
+
import ContextCommandBuilder from "../build/ContextCommandBuilder.js";
|
|
8
|
+
import SlashCommandBuilder from "../build/SlashCommandBuilder.js";
|
|
9
|
+
import ExtensionBuilder from "../build/ExtensionBuilder.js";
|
|
8
10
|
export interface DiscordOptions {
|
|
9
11
|
shards?: number | number[] | "auto";
|
|
10
12
|
closeTimeout?: number;
|
|
@@ -40,9 +42,9 @@ export interface HandlerOptions {
|
|
|
40
42
|
inhibitors?: InhibitorLoadOptions;
|
|
41
43
|
}
|
|
42
44
|
export interface Commands {
|
|
43
|
-
message: Collection<string,
|
|
44
|
-
slash: Collection<string,
|
|
45
|
-
context: Collection<string,
|
|
45
|
+
message: Collection<string, MessageCommandBuilder>;
|
|
46
|
+
slash: Collection<string, SlashCommandBuilder>;
|
|
47
|
+
context: Collection<string, ContextCommandBuilder>;
|
|
46
48
|
}
|
|
47
49
|
export interface Cache {
|
|
48
50
|
messages: Collection<string, object>;
|
|
@@ -56,9 +58,8 @@ export interface Modules {
|
|
|
56
58
|
commandHandler: CommandHandler;
|
|
57
59
|
eventHandler: EventHandler;
|
|
58
60
|
inhibitorHandler: InhibitorHandler;
|
|
59
|
-
webhookHandler: WebhookHandler;
|
|
60
61
|
}
|
|
61
62
|
export interface ExtensionOptions {
|
|
62
|
-
extensions: Array<
|
|
63
|
+
extensions: Array<ExtensionBuilder>;
|
|
63
64
|
logging?: boolean;
|
|
64
65
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventEmitterType } from "../types/Types.js";
|
|
3
|
-
import { MessageCommandUtil } from "../utils/CommandUtil.js";
|
|
1
|
+
import { EventEmitterType, InhibitorType } from "../types/enums.js";
|
|
4
2
|
export interface MessageCommandOptions {
|
|
5
3
|
directory: string;
|
|
6
4
|
prefix: string[] | string;
|
|
@@ -60,12 +58,5 @@ export interface InhibitorLoadOptions {
|
|
|
60
58
|
}
|
|
61
59
|
export interface InhibitorOptions {
|
|
62
60
|
name: string;
|
|
63
|
-
type:
|
|
64
|
-
}
|
|
65
|
-
export interface XernerxMessage extends Message {
|
|
66
|
-
util?: MessageCommandUtil;
|
|
67
|
-
response?: string;
|
|
68
|
-
}
|
|
69
|
-
export interface XernerxUser extends User {
|
|
70
|
-
isOwner: boolean;
|
|
61
|
+
type: InhibitorType;
|
|
71
62
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import DumFunctions from "dumfunctions";
|
|
3
3
|
import XernerxClient from "./client/XernerxClient.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { CommandType, EventEmitterType, ContextCommandType } from "./types/
|
|
10
|
-
import
|
|
4
|
+
import EventBuilder from "./build/EventBuilder.js";
|
|
5
|
+
import InhibitorBuilder from "./build/InhibitorBuilder.js";
|
|
6
|
+
import MessageCommandBuilder from "./build/MessageCommandBuilder.js";
|
|
7
|
+
import ContextCommandBuilder from "./build/ContextCommandBuilder.js";
|
|
8
|
+
import SlashCommandBuilder from "./build/SlashCommandBuilder.js";
|
|
9
|
+
import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from "./types/enums.js";
|
|
10
|
+
import ExtensionBuilder from "./build/ExtensionBuilder.js";
|
|
11
11
|
declare const version: string;
|
|
12
12
|
declare const _default: {
|
|
13
13
|
Discord: typeof Discord;
|
|
@@ -82,12 +82,13 @@ declare const _default: {
|
|
|
82
82
|
EventEmitterType: typeof EventEmitterType;
|
|
83
83
|
InhibitorType: typeof InhibitorType;
|
|
84
84
|
ContextCommandType: typeof ContextCommandType;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
EventBuilder: typeof EventBuilder;
|
|
86
|
+
MessageCommandBuilder: typeof MessageCommandBuilder;
|
|
87
|
+
ContextCommandBuilder: typeof ContextCommandBuilder;
|
|
88
|
+
SlashCommandBuilder: typeof SlashCommandBuilder;
|
|
89
|
+
InhibitorBuilder: typeof InhibitorBuilder;
|
|
90
|
+
ExtensionBuilder: typeof ExtensionBuilder;
|
|
90
91
|
version: string;
|
|
91
92
|
};
|
|
92
93
|
export default _default;
|
|
93
|
-
export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType,
|
|
94
|
+
export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType, EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, version, };
|
package/dist/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import Discord from "discord.js";
|
|
2
2
|
import DumFunctions from "dumfunctions";
|
|
3
3
|
import XernerxClient from "./client/XernerxClient.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { CommandType, EventEmitterType, ContextCommandType } from "./types/
|
|
10
|
-
import
|
|
4
|
+
import EventBuilder from "./build/EventBuilder.js";
|
|
5
|
+
import InhibitorBuilder from "./build/InhibitorBuilder.js";
|
|
6
|
+
import MessageCommandBuilder from "./build/MessageCommandBuilder.js";
|
|
7
|
+
import ContextCommandBuilder from "./build/ContextCommandBuilder.js";
|
|
8
|
+
import SlashCommandBuilder from "./build/SlashCommandBuilder.js";
|
|
9
|
+
import { CommandType, EventEmitterType, ContextCommandType, InhibitorType } from "./types/enums.js";
|
|
10
|
+
import ExtensionBuilder from "./build/ExtensionBuilder.js";
|
|
11
11
|
import pkg from "../package.js";
|
|
12
12
|
const version = pkg.version;
|
|
13
13
|
export default {
|
|
@@ -17,17 +17,18 @@ export default {
|
|
|
17
17
|
// Client
|
|
18
18
|
Client: XernerxClient,
|
|
19
19
|
XernerxClient,
|
|
20
|
-
//
|
|
20
|
+
// Enums
|
|
21
21
|
CommandType,
|
|
22
22
|
EventEmitterType,
|
|
23
23
|
InhibitorType,
|
|
24
24
|
ContextCommandType,
|
|
25
25
|
// Builds
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
EventBuilder,
|
|
27
|
+
MessageCommandBuilder,
|
|
28
|
+
ContextCommandBuilder,
|
|
29
|
+
SlashCommandBuilder,
|
|
30
|
+
InhibitorBuilder,
|
|
31
|
+
ExtensionBuilder,
|
|
31
32
|
// Constants
|
|
32
33
|
version,
|
|
33
34
|
};
|
|
@@ -36,9 +37,9 @@ export {
|
|
|
36
37
|
Discord, DumFunctions,
|
|
37
38
|
// Client
|
|
38
39
|
XernerxClient,
|
|
39
|
-
//
|
|
40
|
+
// Enums
|
|
40
41
|
CommandType, EventEmitterType, InhibitorType, ContextCommandType,
|
|
41
42
|
// Builds
|
|
42
|
-
|
|
43
|
+
EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder,
|
|
43
44
|
// Constants
|
|
44
45
|
version, };
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { MessageCommandBuilder } from "../main.js";
|
|
2
|
+
import { XernerxInteraction, XernerxMessage } from "../types/types.js";
|
|
3
|
+
export declare class InteractionArguments {
|
|
4
|
+
interaction: XernerxInteraction;
|
|
5
|
+
constructor(interaction: XernerxInteraction);
|
|
6
|
+
group(): string | undefined;
|
|
7
|
+
subcommand(): string | undefined;
|
|
7
8
|
arguments(): Record<string, object>;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
interface Flag {
|
|
11
|
+
flags: Record<string, string | boolean>;
|
|
12
|
+
}
|
|
13
|
+
interface Argument {
|
|
14
|
+
[index: string]: string | number | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder): Promise<import("discord.js").Message<boolean> | Flag | Argument | undefined>;
|
|
17
|
+
export {};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export class
|
|
2
|
-
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
1
|
+
export class InteractionArguments {
|
|
2
|
+
interaction;
|
|
3
|
+
constructor(interaction) {
|
|
4
|
+
this.interaction = interaction;
|
|
5
5
|
}
|
|
6
6
|
group() {
|
|
7
|
-
return this.
|
|
7
|
+
return this.interaction?.options?._group;
|
|
8
8
|
}
|
|
9
9
|
subcommand() {
|
|
10
|
-
return this.
|
|
10
|
+
return this.interaction?.options?._subcommand;
|
|
11
11
|
}
|
|
12
12
|
arguments() {
|
|
13
13
|
const options = {};
|
|
14
|
-
if (this.
|
|
15
|
-
for (const option of this.
|
|
14
|
+
if (this.interaction?.options?._hoistedOptions) {
|
|
15
|
+
for (const option of this.interaction.options._hoistedOptions) {
|
|
16
16
|
options[option.name] =
|
|
17
17
|
option.channel || option.user || option.role || option.value;
|
|
18
18
|
}
|
|
@@ -20,13 +20,14 @@ export class CommandArguments {
|
|
|
20
20
|
return options;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
export async function
|
|
23
|
+
export async function messageArguments(message, command) {
|
|
24
24
|
let args = { flags: {} }, separator = command.separator || " ", i = 0;
|
|
25
25
|
if (!command.args)
|
|
26
26
|
return;
|
|
27
27
|
command.args
|
|
28
28
|
.filter((c) => c.type == "flag")
|
|
29
29
|
.map((flag) => {
|
|
30
|
+
args = args;
|
|
30
31
|
for (const flg of message.content.matchAll(flag.content)) {
|
|
31
32
|
if (flag.content == flg) {
|
|
32
33
|
message.content = message.content.replace(flag.content, "");
|
|
@@ -37,6 +38,7 @@ export async function messageArgs(message, command) {
|
|
|
37
38
|
args.flags[flag.name] = false;
|
|
38
39
|
});
|
|
39
40
|
for (const argument of command.args) {
|
|
41
|
+
args = args;
|
|
40
42
|
let content = message.content
|
|
41
43
|
.split(/ +/)
|
|
42
44
|
.slice(1)
|
|
@@ -55,49 +57,47 @@ export async function messageArgs(message, command) {
|
|
|
55
57
|
args[argument.name] = parseInt(content[0]);
|
|
56
58
|
}
|
|
57
59
|
else if (argument.type == "boolean") {
|
|
58
|
-
if (content[0]?.toLowerCase() != "true" &&
|
|
59
|
-
content[0]
|
|
60
|
-
content[0] = undefined;
|
|
60
|
+
if (content[0]?.toLowerCase() != "true" && content[0]?.toLowerCase() != "false")
|
|
61
|
+
content[0] = null;
|
|
61
62
|
args[argument.name] = content[0];
|
|
62
63
|
}
|
|
63
64
|
else if (argument.type == "user") {
|
|
64
|
-
let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0]));
|
|
65
|
+
let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
65
66
|
try {
|
|
66
|
-
user = await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ""));
|
|
67
|
+
user = await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, "")) || null;
|
|
67
68
|
}
|
|
68
69
|
catch (e) {
|
|
69
|
-
user =
|
|
70
|
+
user = null;
|
|
70
71
|
}
|
|
71
72
|
args[argument.name] = user;
|
|
72
73
|
}
|
|
73
74
|
else if (argument.type == "role") {
|
|
74
|
-
let role = message.guild
|
|
75
|
+
let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
|
|
75
76
|
try {
|
|
76
|
-
role = await message.guild
|
|
77
|
+
role = await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, "")) || null;
|
|
77
78
|
}
|
|
78
79
|
catch (e) {
|
|
79
|
-
role =
|
|
80
|
+
role = null;
|
|
80
81
|
}
|
|
81
82
|
args[argument.name] = role;
|
|
82
83
|
}
|
|
83
84
|
else if (argument.type == "member") {
|
|
84
|
-
let member = message.guild
|
|
85
|
-
m?.user?.username?.toLowerCase()?.includes(content[0]));
|
|
85
|
+
let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
86
86
|
try {
|
|
87
|
-
member = await message.guild
|
|
87
|
+
member = await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, "")) || null;
|
|
88
88
|
}
|
|
89
89
|
catch (e) {
|
|
90
|
-
member =
|
|
90
|
+
member = null;
|
|
91
91
|
}
|
|
92
92
|
args[argument.name] = member;
|
|
93
93
|
}
|
|
94
94
|
else if (argument.type == "channel") {
|
|
95
|
-
let channel = message.guild
|
|
95
|
+
let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
|
|
96
96
|
try {
|
|
97
97
|
channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ""));
|
|
98
98
|
}
|
|
99
99
|
catch (e) {
|
|
100
|
-
channel =
|
|
100
|
+
channel = null;
|
|
101
101
|
}
|
|
102
102
|
args[argument.name] = channel;
|
|
103
103
|
}
|
|
@@ -107,22 +107,16 @@ export async function messageArgs(message, command) {
|
|
|
107
107
|
}
|
|
108
108
|
else if (argument.prompt) {
|
|
109
109
|
if (argument.prompt.reply)
|
|
110
|
-
return message.reply(argument.prompt.reply);
|
|
110
|
+
return message.util?.reply(argument.prompt.reply);
|
|
111
111
|
else if (argument.prompt.send)
|
|
112
112
|
return message.channel.send(argument.prompt.send);
|
|
113
113
|
}
|
|
114
114
|
else
|
|
115
|
-
args[argument.name] =
|
|
116
|
-
typeof argument.default == "function"
|
|
117
|
-
? argument.default(message)
|
|
118
|
-
: argument.default;
|
|
115
|
+
args[argument.name] = typeof argument.default == "function" ? argument.default(message) : argument.default;
|
|
119
116
|
i++;
|
|
120
117
|
}
|
|
121
118
|
else
|
|
122
|
-
args[argument.name] =
|
|
123
|
-
typeof argument.default == "function"
|
|
124
|
-
? argument.default(message)
|
|
125
|
-
: argument.default;
|
|
119
|
+
args[argument.name] = typeof argument.default == "function" ? argument.default(message) : argument.default;
|
|
126
120
|
}
|
|
127
121
|
return args;
|
|
128
122
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Interaction
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { Interaction } from "discord.js";
|
|
2
|
+
import { ContextCommandBuilder, MessageCommandBuilder, SlashCommandBuilder, XernerxClient } from "../main.js";
|
|
3
|
+
import { XernerxMessage } from "../types/types.js";
|
|
4
|
+
export default function commandValidation(action: XernerxMessage | Interaction, command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any, client: XernerxClient, res?: boolean): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Message } from "discord.js";
|
|
2
|
-
import { CommandType } from "../types/
|
|
2
|
+
import { CommandType } from "../types/enums.js";
|
|
3
3
|
function getUser(from) {
|
|
4
4
|
if (from instanceof Message)
|
|
5
5
|
return from.author;
|
|
@@ -8,8 +8,7 @@ function getUser(from) {
|
|
|
8
8
|
}
|
|
9
9
|
export default function commandValidation(action, command, client, res = false) {
|
|
10
10
|
let user = getUser(action);
|
|
11
|
-
if ((command.ignoreOwner || client.settings.ignoreOwner) &&
|
|
12
|
-
client.util.isOwner(user.id))
|
|
11
|
+
if ((command.ignoreOwner || client.settings.ignoreOwner) && client.util.isOwner(user.id))
|
|
13
12
|
return res;
|
|
14
13
|
else if (inCooldown(user, client, command, action))
|
|
15
14
|
return true;
|
|
@@ -25,20 +24,16 @@ export default function commandValidation(action, command, client, res = false)
|
|
|
25
24
|
emit(client, action, command, "Not the correct channel", command.channelType);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
else if (command.channels?.length > 0 &&
|
|
29
|
-
!command.channels.includes(action.channel?.id)) {
|
|
27
|
+
else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
|
|
30
28
|
res = true;
|
|
31
29
|
emit(client, action, command, "Not a whitelisted channel", command.channels);
|
|
32
30
|
}
|
|
33
|
-
else if (command.guilds?.length > 0 &&
|
|
34
|
-
!command.guilds.includes(action.guild?.id)) {
|
|
31
|
+
else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
|
|
35
32
|
res = true;
|
|
36
33
|
emit(client, action, command, "Not a whitelisted guild", command.guilds);
|
|
37
34
|
}
|
|
38
|
-
else if (action?.guild &&
|
|
39
|
-
|
|
40
|
-
const permissions = command.userPermissions ||
|
|
41
|
-
client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, "user")), missing = [];
|
|
35
|
+
else if (action?.guild && (command.userPermissions || client.settings.userPermissions)) {
|
|
36
|
+
const permissions = command.userPermissions || client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, "user")), missing = [];
|
|
42
37
|
if (Array.isArray(permissions))
|
|
43
38
|
permissions.map((permission) => {
|
|
44
39
|
if (!(action.member?.permissions).has(permission)) {
|
|
@@ -50,10 +45,8 @@ export default function commandValidation(action, command, client, res = false)
|
|
|
50
45
|
emit(client, action, command, "Missing User Permissions", missing);
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
|
-
else if (action?.guild &&
|
|
54
|
-
|
|
55
|
-
const permissions = command.clientPermissions ||
|
|
56
|
-
client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, "client")), missing = [];
|
|
48
|
+
else if (action?.guild && (command.clientPermissions || client.settings.clientPermissions)) {
|
|
49
|
+
const permissions = command.clientPermissions || client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, "client")), missing = [];
|
|
57
50
|
if (Array.isArray(permissions))
|
|
58
51
|
permissions.map((permission) => {
|
|
59
52
|
if (!(action.member?.permissions).has(permission)) {
|
|
@@ -73,8 +66,7 @@ function emit(client, action, command, reason, extra) {
|
|
|
73
66
|
function inCooldown(user, client, command, action) {
|
|
74
67
|
let res = false, downs = {};
|
|
75
68
|
const { cooldowns, messageCommands, slashCommands, contextCommands, commands, } = client.cache;
|
|
76
|
-
if (command.commandType === CommandType.MessageCommand &&
|
|
77
|
-
client.handlerOptions.message.cooldown) {
|
|
69
|
+
if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
|
|
78
70
|
if (messageCommands.has(user.id)) {
|
|
79
71
|
const usr = messageCommands.get(user.id);
|
|
80
72
|
usr.timeRemaining = usr.endsAt - Date.now();
|