xernerx 3.2.6 → 3.3.1
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 +1 -1
- 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 +110 -0
- package/dist/build/XernerxExtension.d.ts +7 -0
- package/dist/build/XernerxExtension.js +9 -0
- package/dist/client/XernerxClient.d.ts +13 -9
- package/dist/client/XernerxClient.js +12 -12
- 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 +4 -4
- package/dist/handlers/InhibitorHandler.js +1 -1
- 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 +19 -16
- package/dist/main.js +22 -19
- package/dist/models/CommandArguments.d.ts +15 -7
- package/dist/models/CommandArguments.js +42 -49
- 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/tools/XernerxError.js +2 -2
- 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.d.ts +2 -2
- package/dist/utils/ClientUtil.js +12 -27
- package/dist/utils/CommandUtil.d.ts +5 -5
- package/dist/utils/CommandUtil.js +24 -45
- package/package.json +1 -1
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { Client, Collection } from
|
|
2
|
-
import { ClientUtil } from
|
|
3
|
-
import {
|
|
1
|
+
import { Client, Collection } from 'discord.js';
|
|
2
|
+
import { ClientUtil } from '../utils/ClientUtil.js';
|
|
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;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Client, Collection } from
|
|
2
|
-
import { s } from
|
|
3
|
-
import CommandHandler from
|
|
4
|
-
import EventHandler from
|
|
5
|
-
import InhibitorHandler from
|
|
6
|
-
import { ClientUtil } from
|
|
7
|
-
import { Style } from
|
|
8
|
-
import
|
|
9
|
-
import Extensions from "../models/Extensions.js";
|
|
1
|
+
import { Client, Collection } from 'discord.js';
|
|
2
|
+
import { s } from '@sapphire/shapeshift';
|
|
3
|
+
import CommandHandler from '../handlers/CommandHandler.js';
|
|
4
|
+
import EventHandler from '../handlers/EventHandler.js';
|
|
5
|
+
import InhibitorHandler from '../handlers/InhibitorHandler.js';
|
|
6
|
+
import { ClientUtil } from '../utils/ClientUtil.js';
|
|
7
|
+
import { Style } from 'dumfunctions';
|
|
8
|
+
import Extensions from '../models/Extensions.js';
|
|
10
9
|
/**
|
|
11
10
|
* @description - The Client.
|
|
12
11
|
* @param {DiscordOptions} discordOptions - The options for discord.js.
|
|
@@ -59,15 +58,16 @@ 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);
|
|
66
64
|
this.handlerOptions = {};
|
|
67
65
|
if (this.settings.logging) {
|
|
68
|
-
this.once(
|
|
66
|
+
this.once('ready', async (client) => {
|
|
69
67
|
const size = (await client.guilds.fetch()).size;
|
|
70
|
-
console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ?
|
|
68
|
+
console.info(Style.log(`Xernerx | ${client.user.tag} signed in watching ${size} server${size > 1 ? 's' : ''}. ${(this.handlerOptions.slash || this.handlerOptions.context)?.guildId
|
|
69
|
+
? `Using ${(await this.guilds.fetch((this.handlerOptions.slash || this.handlerOptions.context)?.guildId || '0')).name} as local guild.`
|
|
70
|
+
: ''}`, { color: Style.TextColor.Purple }));
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
this.register = this.register;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Handler } from
|
|
1
|
+
import XernerxClient from '../client/XernerxClient.js';
|
|
2
|
+
import { InhibitorHandlerOptions } from '../types/options.js';
|
|
3
|
+
import { Handler } from './Handler.js';
|
|
4
4
|
/**
|
|
5
5
|
* @description - Inhibitor loader.
|
|
6
6
|
* @param {XernerxClient} client - The XernerxClient.
|
|
@@ -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,14 @@
|
|
|
1
|
-
import Discord from
|
|
2
|
-
import DumFunctions from
|
|
3
|
-
import XernerxClient from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { CommandType, EventEmitterType, ContextCommandType } from
|
|
10
|
-
import
|
|
1
|
+
import Discord from 'discord.js';
|
|
2
|
+
import DumFunctions from 'dumfunctions';
|
|
3
|
+
import XernerxClient from './client/XernerxClient.js';
|
|
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 XernerxError from './tools/XernerxError.js';
|
|
11
|
+
import ExtensionBuilder from './build/ExtensionBuilder.js';
|
|
11
12
|
declare const version: string;
|
|
12
13
|
declare const _default: {
|
|
13
14
|
Discord: typeof Discord;
|
|
@@ -82,12 +83,14 @@ declare const _default: {
|
|
|
82
83
|
EventEmitterType: typeof EventEmitterType;
|
|
83
84
|
InhibitorType: typeof InhibitorType;
|
|
84
85
|
ContextCommandType: typeof ContextCommandType;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
EventBuilder: typeof EventBuilder;
|
|
87
|
+
MessageCommandBuilder: typeof MessageCommandBuilder;
|
|
88
|
+
ContextCommandBuilder: typeof ContextCommandBuilder;
|
|
89
|
+
SlashCommandBuilder: typeof SlashCommandBuilder;
|
|
90
|
+
InhibitorBuilder: typeof InhibitorBuilder;
|
|
91
|
+
ExtensionBuilder: typeof ExtensionBuilder;
|
|
92
|
+
XernerxError: typeof XernerxError;
|
|
90
93
|
version: string;
|
|
91
94
|
};
|
|
92
95
|
export default _default;
|
|
93
|
-
export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType,
|
|
96
|
+
export { Discord, DumFunctions, XernerxClient, CommandType, EventEmitterType, InhibitorType, ContextCommandType, EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, XernerxError, version, };
|
package/dist/main.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import Discord from
|
|
2
|
-
import DumFunctions from
|
|
3
|
-
import XernerxClient from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { CommandType, EventEmitterType, ContextCommandType } from
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import Discord from 'discord.js';
|
|
2
|
+
import DumFunctions from 'dumfunctions';
|
|
3
|
+
import XernerxClient from './client/XernerxClient.js';
|
|
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 XernerxError from './tools/XernerxError.js';
|
|
11
|
+
import ExtensionBuilder from './build/ExtensionBuilder.js';
|
|
12
|
+
import pkg from '../package.js';
|
|
12
13
|
const version = pkg.version;
|
|
13
14
|
export default {
|
|
14
15
|
// Imported methods
|
|
@@ -17,17 +18,19 @@ export default {
|
|
|
17
18
|
// Client
|
|
18
19
|
Client: XernerxClient,
|
|
19
20
|
XernerxClient,
|
|
20
|
-
//
|
|
21
|
+
// Enums
|
|
21
22
|
CommandType,
|
|
22
23
|
EventEmitterType,
|
|
23
24
|
InhibitorType,
|
|
24
25
|
ContextCommandType,
|
|
25
26
|
// Builds
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
EventBuilder,
|
|
28
|
+
MessageCommandBuilder,
|
|
29
|
+
ContextCommandBuilder,
|
|
30
|
+
SlashCommandBuilder,
|
|
31
|
+
InhibitorBuilder,
|
|
32
|
+
ExtensionBuilder,
|
|
33
|
+
XernerxError,
|
|
31
34
|
// Constants
|
|
32
35
|
version,
|
|
33
36
|
};
|
|
@@ -36,9 +39,9 @@ export {
|
|
|
36
39
|
Discord, DumFunctions,
|
|
37
40
|
// Client
|
|
38
41
|
XernerxClient,
|
|
39
|
-
//
|
|
42
|
+
// Enums
|
|
40
43
|
CommandType, EventEmitterType, InhibitorType, ContextCommandType,
|
|
41
44
|
// Builds
|
|
42
|
-
|
|
45
|
+
EventBuilder, MessageCommandBuilder, ContextCommandBuilder, SlashCommandBuilder, InhibitorBuilder, ExtensionBuilder, XernerxError,
|
|
43
46
|
// Constants
|
|
44
47
|
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,35 +1,35 @@
|
|
|
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.
|
|
16
|
-
options[option.name] =
|
|
17
|
-
option.channel || option.user || option.role || option.value;
|
|
14
|
+
if (this.interaction?.options?._hoistedOptions) {
|
|
15
|
+
for (const option of this.interaction.options._hoistedOptions) {
|
|
16
|
+
options[option.name] = option.channel || option.user || option.role || option.value;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
return options;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
|
-
export async function
|
|
24
|
-
let args = { flags: {} }, separator = command.separator ||
|
|
22
|
+
export async function messageArguments(message, command) {
|
|
23
|
+
let args = { flags: {} }, separator = command.separator || ' ', i = 0;
|
|
25
24
|
if (!command.args)
|
|
26
25
|
return;
|
|
27
26
|
command.args
|
|
28
|
-
.filter((c) => c.type ==
|
|
27
|
+
.filter((c) => c.type == 'flag')
|
|
29
28
|
.map((flag) => {
|
|
29
|
+
args = args;
|
|
30
30
|
for (const flg of message.content.matchAll(flag.content)) {
|
|
31
31
|
if (flag.content == flg) {
|
|
32
|
-
message.content = message.content.replace(flag.content,
|
|
32
|
+
message.content = message.content.replace(flag.content, '');
|
|
33
33
|
args.flags[flag.name] = true;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -37,92 +37,85 @@ export async function messageArgs(message, command) {
|
|
|
37
37
|
args.flags[flag.name] = false;
|
|
38
38
|
});
|
|
39
39
|
for (const argument of command.args) {
|
|
40
|
+
args = args;
|
|
40
41
|
let content = message.content
|
|
41
42
|
.split(/ +/)
|
|
42
43
|
.slice(1)
|
|
43
44
|
.join(separator)
|
|
44
|
-
.replace(new RegExp(`${separator}${separator}+`,
|
|
45
|
+
.replace(new RegExp(`${separator}${separator}+`, 'g'), separator)
|
|
45
46
|
.split(separator)
|
|
46
47
|
.slice(i);
|
|
47
|
-
if (content.join(separator) !=
|
|
48
|
+
if (content.join(separator) != '' && argument.type !== 'flag') {
|
|
48
49
|
if (argument?.content?.includes(content[0])) {
|
|
49
50
|
args[argument.name] = content[0];
|
|
50
51
|
}
|
|
51
|
-
else if (argument.type ==
|
|
52
|
+
else if (argument.type == 'string') {
|
|
52
53
|
args[argument.name] = content[0];
|
|
53
54
|
}
|
|
54
|
-
else if (argument.type ==
|
|
55
|
+
else if (argument.type == 'number') {
|
|
55
56
|
args[argument.name] = parseInt(content[0]);
|
|
56
57
|
}
|
|
57
|
-
else if (argument.type ==
|
|
58
|
-
if (content[0]?.toLowerCase() !=
|
|
59
|
-
content[0]
|
|
60
|
-
content[0] = undefined;
|
|
58
|
+
else if (argument.type == 'boolean') {
|
|
59
|
+
if (content[0]?.toLowerCase() != 'true' && content[0]?.toLowerCase() != 'false')
|
|
60
|
+
content[0] = null;
|
|
61
61
|
args[argument.name] = content[0];
|
|
62
62
|
}
|
|
63
|
-
else if (argument.type ==
|
|
64
|
-
let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0]));
|
|
63
|
+
else if (argument.type == 'user') {
|
|
64
|
+
let user = message.client.users.cache.find((u) => u?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
65
65
|
try {
|
|
66
|
-
user = await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g,
|
|
66
|
+
user = (await message.client.users.fetch(user?.id || content[0].replace(/<@!?|>/g, ''))) || null;
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
user =
|
|
69
|
+
user = null;
|
|
70
70
|
}
|
|
71
71
|
args[argument.name] = user;
|
|
72
72
|
}
|
|
73
|
-
else if (argument.type ==
|
|
74
|
-
let role = message.guild
|
|
73
|
+
else if (argument.type == 'role') {
|
|
74
|
+
let role = message.guild?.roles.cache.find((r) => r?.name?.toLowerCase()?.includes(content[0])) || null;
|
|
75
75
|
try {
|
|
76
|
-
role = await message.guild
|
|
76
|
+
role = (await message.guild?.roles.fetch(role?.id || content[0].replace(/<@&?|>/g, ''))) || null;
|
|
77
77
|
}
|
|
78
78
|
catch (e) {
|
|
79
|
-
role =
|
|
79
|
+
role = null;
|
|
80
80
|
}
|
|
81
81
|
args[argument.name] = role;
|
|
82
82
|
}
|
|
83
|
-
else if (argument.type ==
|
|
84
|
-
let member = message.guild
|
|
85
|
-
m?.user?.username?.toLowerCase()?.includes(content[0]));
|
|
83
|
+
else if (argument.type == 'member') {
|
|
84
|
+
let member = message.guild?.members.cache.find((m) => m?.nickname?.toLowerCase()?.includes(content[0]) || m?.user?.username?.toLowerCase()?.includes(content[0])) || null;
|
|
86
85
|
try {
|
|
87
|
-
member = await message.guild
|
|
86
|
+
member = (await message.guild?.members.fetch(member?.id || content[0].replace(/<@!?|>/g, ''))) || null;
|
|
88
87
|
}
|
|
89
88
|
catch (e) {
|
|
90
|
-
member =
|
|
89
|
+
member = null;
|
|
91
90
|
}
|
|
92
91
|
args[argument.name] = member;
|
|
93
92
|
}
|
|
94
|
-
else if (argument.type ==
|
|
95
|
-
let channel = message.guild
|
|
93
|
+
else if (argument.type == 'channel') {
|
|
94
|
+
let channel = message.guild?.channels.cache.find((c) => c?.name?.toLowerCase()?.includes(content[0]));
|
|
96
95
|
try {
|
|
97
|
-
channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g,
|
|
96
|
+
channel = await message.client.channels.fetch(channel?.id || content[0].replace(/<#|>/g, ''));
|
|
98
97
|
}
|
|
99
98
|
catch (e) {
|
|
100
|
-
channel =
|
|
99
|
+
channel = null;
|
|
101
100
|
}
|
|
102
101
|
args[argument.name] = channel;
|
|
103
102
|
}
|
|
104
|
-
else if (argument.type ==
|
|
103
|
+
else if (argument.type == 'rest') {
|
|
105
104
|
args[argument.name] = content.join(separator);
|
|
106
105
|
break;
|
|
107
106
|
}
|
|
108
107
|
else if (argument.prompt) {
|
|
109
108
|
if (argument.prompt.reply)
|
|
110
|
-
return message.reply(argument.prompt.reply);
|
|
109
|
+
return message.util?.reply(argument.prompt.reply);
|
|
111
110
|
else if (argument.prompt.send)
|
|
112
111
|
return message.channel.send(argument.prompt.send);
|
|
113
112
|
}
|
|
114
113
|
else
|
|
115
|
-
args[argument.name] =
|
|
116
|
-
typeof argument.default == "function"
|
|
117
|
-
? argument.default(message)
|
|
118
|
-
: argument.default;
|
|
114
|
+
args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
119
115
|
i++;
|
|
120
116
|
}
|
|
121
117
|
else
|
|
122
|
-
args[argument.name] =
|
|
123
|
-
typeof argument.default == "function"
|
|
124
|
-
? argument.default(message)
|
|
125
|
-
: argument.default;
|
|
118
|
+
args[argument.name] = typeof argument.default == 'function' ? argument.default(message) : argument.default;
|
|
126
119
|
}
|
|
127
120
|
return args;
|
|
128
121
|
}
|
|
@@ -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;
|