xernerx 4.17.7 → 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 +20 -46
- package/dist/main.js +23 -49
- package/dist/main.js.map +1 -0
- package/package.json +63 -47
- package/src/main.ts +26 -0
- package/dist/build/XernerxContextCommand.d.ts +0 -82
- package/dist/build/XernerxContextCommand.js +0 -125
- package/dist/build/XernerxEvent.d.ts +0 -21
- package/dist/build/XernerxEvent.js +0 -27
- package/dist/build/XernerxInhibitor.d.ts +0 -53
- package/dist/build/XernerxInhibitor.js +0 -27
- package/dist/build/XernerxMessageCommand.d.ts +0 -84
- package/dist/build/XernerxMessageCommand.js +0 -123
- package/dist/build/XernerxSlashCommand.d.ts +0 -104
- package/dist/build/XernerxSlashCommand.js +0 -182
- package/dist/client/XernerxClient.d.ts +0 -70
- package/dist/client/XernerxClient.js +0 -106
- package/dist/client/XernerxShardClient.d.ts +0 -21
- package/dist/client/XernerxShardClient.js +0 -67
- package/dist/functions/deploy.d.ts +0 -3
- package/dist/functions/deploy.js +0 -56
- package/dist/functions/load.d.ts +0 -4
- package/dist/functions/load.js +0 -34
- package/dist/functions/reload.d.ts +0 -3
- package/dist/functions/reload.js +0 -29
- package/dist/functions/setPresence.d.ts +0 -4
- package/dist/functions/setPresence.js +0 -22
- package/dist/functions/xernerxUser.d.ts +0 -4
- package/dist/functions/xernerxUser.js +0 -10
- package/dist/handlers/CommandHandler.d.ts +0 -16
- package/dist/handlers/CommandHandler.js +0 -326
- package/dist/handlers/EventHandler.d.ts +0 -9
- package/dist/handlers/EventHandler.js +0 -56
- package/dist/handlers/ExtensionHandler.d.ts +0 -9
- package/dist/handlers/ExtensionHandler.js +0 -29
- package/dist/handlers/Handler.d.ts +0 -31
- package/dist/handlers/Handler.js +0 -52
- package/dist/handlers/InhibitorHandler.d.ts +0 -9
- package/dist/handlers/InhibitorHandler.js +0 -33
- package/dist/handlers/IntegrationHandler.d.ts +0 -15
- package/dist/handlers/IntegrationHandler.js +0 -26
- package/dist/models/Arguments.d.ts +0 -12
- package/dist/models/Arguments.js +0 -139
- package/dist/models/Cooldowns.d.ts +0 -11
- package/dist/models/Cooldowns.js +0 -29
- 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 -148
- package/dist/tools/XernerxText.d.ts +0 -31
- package/dist/tools/XernerxText.js +0 -84
- package/dist/types/extenders.d.ts +0 -84
- package/dist/types/extenders.js +0 -2
- package/dist/types/interfaces.d.ts +0 -263
- package/dist/types/interfaces.js +0 -2
- package/dist/types/types.d.ts +0 -111
- package/dist/types/types.js +0 -2
- package/dist/utils/ClientUtil.d.ts +0 -22
- package/dist/utils/ClientUtil.js +0 -102
- package/dist/utils/InteractionUtil.d.ts +0 -25
- package/dist/utils/InteractionUtil.js +0 -154
- package/dist/utils/MessageUtil.d.ts +0 -26
- package/dist/utils/MessageUtil.js +0 -168
- package/dist/utils/Util.d.ts +0 -12
- package/dist/utils/Util.js +0 -11
- package/dist/validators/commandValidation.d.ts +0 -10
- package/dist/validators/commandValidation.js +0 -167
- package/dist/validators/inhibitorValidations.d.ts +0 -28
- package/dist/validators/inhibitorValidations.js +0 -44
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import Discord, { 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 Discord.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(
|
|
35
|
-
z.enum([
|
|
36
|
-
'GuildText',
|
|
37
|
-
'DM',
|
|
38
|
-
'GuildVoice',
|
|
39
|
-
'GroupDM',
|
|
40
|
-
'GuildCategory',
|
|
41
|
-
'GuildAnnouncement',
|
|
42
|
-
'AnnouncementThread',
|
|
43
|
-
'PublicThread',
|
|
44
|
-
'PrivateThread',
|
|
45
|
-
'GuildStageVoice',
|
|
46
|
-
'GuildDirectory',
|
|
47
|
-
'GuildForum',
|
|
48
|
-
'GuildNews',
|
|
49
|
-
'GuildNewsThread',
|
|
50
|
-
'GuildPublicThread',
|
|
51
|
-
'GuildPrivateThread',
|
|
52
|
-
])
|
|
53
|
-
)
|
|
54
|
-
.or(
|
|
55
|
-
z.enum([
|
|
56
|
-
'GuildText',
|
|
57
|
-
'DM',
|
|
58
|
-
'GuildVoice',
|
|
59
|
-
'GroupDM',
|
|
60
|
-
'GuildCategory',
|
|
61
|
-
'GuildAnnouncement',
|
|
62
|
-
'AnnouncementThread',
|
|
63
|
-
'PublicThread',
|
|
64
|
-
'PrivateThread',
|
|
65
|
-
'GuildStageVoice',
|
|
66
|
-
'GuildDirectory',
|
|
67
|
-
'GuildForum',
|
|
68
|
-
'GuildNews',
|
|
69
|
-
'GuildNewsThread',
|
|
70
|
-
'GuildPublicThread',
|
|
71
|
-
'GuildPrivateThread',
|
|
72
|
-
])
|
|
73
|
-
)
|
|
74
|
-
.or(z.null())
|
|
75
|
-
.default(null),
|
|
76
|
-
ignore: z
|
|
77
|
-
.object({
|
|
78
|
-
owner: z.boolean().default(false),
|
|
79
|
-
users: z.array(z.string()).default([]),
|
|
80
|
-
channels: z.array(z.string()).default([]),
|
|
81
|
-
guilds: z.array(z.string()).default([]),
|
|
82
|
-
voice: z.boolean().default(false),
|
|
83
|
-
})
|
|
84
|
-
.default({}),
|
|
85
|
-
strict: z
|
|
86
|
-
.object({
|
|
87
|
-
owner: z.boolean().default(false),
|
|
88
|
-
users: z.array(z.string()).default([]),
|
|
89
|
-
channels: z.array(z.string()).default([]),
|
|
90
|
-
guilds: z.array(z.string()).default([]),
|
|
91
|
-
voice: z.boolean().default(false),
|
|
92
|
-
})
|
|
93
|
-
.default({}),
|
|
94
|
-
permissions: z
|
|
95
|
-
.object({
|
|
96
|
-
user: z.array(z.string()).or(z.null()).default(null),
|
|
97
|
-
client: z.array(z.string()).or(z.null()).default(null),
|
|
98
|
-
dm: z.boolean().default(true),
|
|
99
|
-
})
|
|
100
|
-
.default({}),
|
|
101
|
-
defer: z
|
|
102
|
-
.object({
|
|
103
|
-
reply: z.boolean().optional(),
|
|
104
|
-
ephemeral: z.boolean().optional(),
|
|
105
|
-
fetch: z.boolean().optional(),
|
|
106
|
-
})
|
|
107
|
-
.default({}),
|
|
108
|
-
})
|
|
109
|
-
.parse(options);
|
|
110
|
-
this.name = options.name;
|
|
111
|
-
this.description = options.description;
|
|
112
|
-
this.usage = options.usage;
|
|
113
|
-
this.info = options.info;
|
|
114
|
-
this.category = options.category;
|
|
115
|
-
this.cooldown = options.cooldown;
|
|
116
|
-
this.channel = options.channel ? (Array.isArray(options.channel) ? options.channel : [options.channel]) : null;
|
|
117
|
-
this.global = options.global;
|
|
118
|
-
this.ignore = options.ignore;
|
|
119
|
-
this.strict = options.strict;
|
|
120
|
-
this.permissions = options.permissions;
|
|
121
|
-
this.defer = options.defer;
|
|
122
|
-
this.client = this.client;
|
|
123
|
-
this.util = this.util;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @description autocomplete let's you add choices to string option arguments
|
|
127
|
-
* @param interaction - The interaction event emitted on this command
|
|
128
|
-
* @param focused - The command option that is in focus
|
|
129
|
-
* @param options - The full list of options on the command
|
|
130
|
-
*/
|
|
131
|
-
async autocomplete(interaction, focused, options) {}
|
|
132
|
-
/**
|
|
133
|
-
* @description Checks for conditions before running the command
|
|
134
|
-
* @param interaction - The interaction event emitted on this command
|
|
135
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
136
|
-
*/
|
|
137
|
-
async conditions(interaction, { args, subcommand, group }) {}
|
|
138
|
-
/**
|
|
139
|
-
* @description Runs the execution rule
|
|
140
|
-
* @param interaction - The interaction event emitted on this command
|
|
141
|
-
* @param options - The args, group and subcommand parsed on this command
|
|
142
|
-
*/
|
|
143
|
-
async exec(interaction, { args, subcommand, group }) {
|
|
144
|
-
new XernerxLog(this.client).error(`${this.id} doesn't have an execution rule.`);
|
|
145
|
-
return await this.client.emit('commandError', interaction, `${this.id} doesn't have an execution rule.`, this);
|
|
146
|
-
}
|
|
147
|
-
addArguments(command, args) {
|
|
148
|
-
for (const argument of args) {
|
|
149
|
-
let slashCommandArgumentType = `${argument.type.charAt(0).toUpperCase()}${argument.type.slice(1).toLowerCase()}`;
|
|
150
|
-
command[`add${slashCommandArgumentType}Option`]((option) => {
|
|
151
|
-
option
|
|
152
|
-
.setName(argument.name)
|
|
153
|
-
.setDescription(argument.description)
|
|
154
|
-
.setRequired(argument.required || false);
|
|
155
|
-
if (slashCommandArgumentType === 'String') {
|
|
156
|
-
if (argument.choices)
|
|
157
|
-
option.setChoices(
|
|
158
|
-
...argument.choices.map((choices) => {
|
|
159
|
-
return { name: Object.keys(choices).at(0), value: Object.values(choices).at(0) };
|
|
160
|
-
})
|
|
161
|
-
);
|
|
162
|
-
option.setAutocomplete(argument.autocomplete || false);
|
|
163
|
-
}
|
|
164
|
-
return option;
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
addSubcommands(method, subcommands) {
|
|
169
|
-
for (const subcommand of subcommands) {
|
|
170
|
-
let sub = new SlashCommandSubcommandBuilder().setName(subcommand.name).setDescription(subcommand.description);
|
|
171
|
-
if (subcommand.args && subcommand?.args?.length > 0) this.addArguments(sub, subcommand.args);
|
|
172
|
-
method.addSubcommand(sub);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
addSubcommandGroups(groups) {
|
|
176
|
-
for (const group of groups) {
|
|
177
|
-
let subcommandGroup = new SlashCommandSubcommandGroupBuilder().setName(group.name).setDescription(group.description);
|
|
178
|
-
if (group.subcommands?.length > 0) this.addSubcommands(subcommandGroup, group.subcommands);
|
|
179
|
-
this.data.addSubcommandGroup(subcommandGroup);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
@@ -1,70 +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<
|
|
10
|
-
T extends object = {
|
|
11
|
-
[index: string | number]: any;
|
|
12
|
-
},
|
|
13
|
-
> extends Client {
|
|
14
|
-
readonly settings: {
|
|
15
|
-
ownerId: (string | string[]) & (string | string[] | undefined);
|
|
16
|
-
local: string;
|
|
17
|
-
ceaseless: boolean;
|
|
18
|
-
global?: boolean | undefined;
|
|
19
|
-
debug?: boolean | undefined;
|
|
20
|
-
permissions?:
|
|
21
|
-
| {
|
|
22
|
-
user: string[] | null;
|
|
23
|
-
client: string[] | null;
|
|
24
|
-
dm: boolean;
|
|
25
|
-
}
|
|
26
|
-
| undefined;
|
|
27
|
-
ignore?:
|
|
28
|
-
| {
|
|
29
|
-
system: boolean;
|
|
30
|
-
users: string[];
|
|
31
|
-
owner: boolean;
|
|
32
|
-
self: boolean;
|
|
33
|
-
bots: boolean;
|
|
34
|
-
channels: string[];
|
|
35
|
-
guilds: string[];
|
|
36
|
-
}
|
|
37
|
-
| undefined;
|
|
38
|
-
log?:
|
|
39
|
-
| boolean
|
|
40
|
-
| {
|
|
41
|
-
warn: boolean;
|
|
42
|
-
error: boolean;
|
|
43
|
-
ready: boolean;
|
|
44
|
-
info: boolean;
|
|
45
|
-
table: string[] | null;
|
|
46
|
-
format: string[] | null;
|
|
47
|
-
}
|
|
48
|
-
| undefined;
|
|
49
|
-
cooldown?:
|
|
50
|
-
| {
|
|
51
|
-
command: number;
|
|
52
|
-
cache: number;
|
|
53
|
-
collections: string[];
|
|
54
|
-
}
|
|
55
|
-
| undefined;
|
|
56
|
-
};
|
|
57
|
-
readonly config: T;
|
|
58
|
-
readonly commands: XernerxCommands;
|
|
59
|
-
readonly events: Collection<string, XernerxEvent<keyof XernerxClientEvents>>;
|
|
60
|
-
readonly inhibitors: Collection<string, XernerxInhibitor>;
|
|
61
|
-
readonly modules: ModuleOptions;
|
|
62
|
-
readonly util: ClientUtil;
|
|
63
|
-
readonly stats: Record<string, number>;
|
|
64
|
-
readonly cache: XernerxCache;
|
|
65
|
-
readonly cooldowns: Cooldowns;
|
|
66
|
-
readonly dbl: any;
|
|
67
|
-
readonly [index: string]: unknown;
|
|
68
|
-
constructor(discordOptions: ClientOptions, xernerxOptions: XernerxOptions, config?: T);
|
|
69
|
-
connect(token: string): Promise<string | void>;
|
|
70
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Client, Collection } from 'discord.js';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
import * as clack from '@clack/prompts';
|
|
5
|
-
import CommandHandler from '../handlers/CommandHandler.js';
|
|
6
|
-
import EventHandler from '../handlers/EventHandler.js';
|
|
7
|
-
import InhibitorHandler from '../handlers/InhibitorHandler.js';
|
|
8
|
-
import IntegrationHandler from '../handlers/IntegrationHandler.js';
|
|
9
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
10
|
-
import ClientUtil from '../utils/ClientUtil.js';
|
|
11
|
-
import ExtensionHandler from '../handlers/ExtensionHandler.js';
|
|
12
|
-
import deploy from '../functions/deploy.js';
|
|
13
|
-
import Cooldowns from '../models/Cooldowns.js';
|
|
14
|
-
export default class XernerxClient extends Client {
|
|
15
|
-
constructor(discordOptions, xernerxOptions, config) {
|
|
16
|
-
super(discordOptions);
|
|
17
|
-
clack.intro('Xernerx');
|
|
18
|
-
this.settings = z
|
|
19
|
-
.object({
|
|
20
|
-
local: z.string(),
|
|
21
|
-
global: z.boolean().default(false).optional(),
|
|
22
|
-
debug: z.boolean().default(false).optional(),
|
|
23
|
-
ownerId: z.string().or(z.array(z.string())).default([]),
|
|
24
|
-
ceaseless: z.boolean().default(false),
|
|
25
|
-
permissions: z
|
|
26
|
-
.object({
|
|
27
|
-
client: z.array(z.string()).or(z.null()).default(null),
|
|
28
|
-
user: z.array(z.string()).or(z.null()).default(null),
|
|
29
|
-
dm: z.boolean().default(false),
|
|
30
|
-
})
|
|
31
|
-
.optional(),
|
|
32
|
-
ignore: z
|
|
33
|
-
.object({
|
|
34
|
-
owner: z.boolean().default(false),
|
|
35
|
-
self: z.boolean().default(true),
|
|
36
|
-
bots: z.boolean().default(true),
|
|
37
|
-
system: z.boolean().default(true),
|
|
38
|
-
users: z.array(z.string()).default([]),
|
|
39
|
-
channels: z.array(z.string()).default([]),
|
|
40
|
-
guilds: z.array(z.string()).default([]),
|
|
41
|
-
})
|
|
42
|
-
.optional(),
|
|
43
|
-
log: z
|
|
44
|
-
.object({
|
|
45
|
-
ready: z.boolean().default(false),
|
|
46
|
-
info: z.boolean().default(false),
|
|
47
|
-
warn: z.boolean().default(false),
|
|
48
|
-
error: z.boolean().default(false),
|
|
49
|
-
table: z.array(z.string()).or(z.null()).default(null),
|
|
50
|
-
format: z.array(z.string()).or(z.null()).default(null),
|
|
51
|
-
})
|
|
52
|
-
.or(z.boolean())
|
|
53
|
-
.optional(),
|
|
54
|
-
cooldown: z
|
|
55
|
-
.object({
|
|
56
|
-
command: z.number().default(0),
|
|
57
|
-
cache: z.number().default(0),
|
|
58
|
-
collections: z.array(z.string()).default(['commands']),
|
|
59
|
-
})
|
|
60
|
-
.optional(),
|
|
61
|
-
})
|
|
62
|
-
.parse(xernerxOptions);
|
|
63
|
-
this.config = config;
|
|
64
|
-
this.commands = {
|
|
65
|
-
message: new Collection(),
|
|
66
|
-
slash: new Collection(),
|
|
67
|
-
context: new Collection(),
|
|
68
|
-
};
|
|
69
|
-
this.events = new Collection();
|
|
70
|
-
this.inhibitors = new Collection();
|
|
71
|
-
this.util = new ClientUtil(this);
|
|
72
|
-
this.stats = {
|
|
73
|
-
guildCount: this.guilds.cache.size,
|
|
74
|
-
userCount: 0,
|
|
75
|
-
shardId: 0,
|
|
76
|
-
shardCount: this.options.shardCount || 1,
|
|
77
|
-
voteCount: 0,
|
|
78
|
-
};
|
|
79
|
-
this.dbl = {};
|
|
80
|
-
this.cache = {
|
|
81
|
-
messages: new Collection(),
|
|
82
|
-
cooldowns: new Collection(),
|
|
83
|
-
};
|
|
84
|
-
this.cooldowns = new Cooldowns(this, xernerxOptions.cooldown?.collections);
|
|
85
|
-
this.modules = {
|
|
86
|
-
options: {},
|
|
87
|
-
commandHandler: new CommandHandler(this),
|
|
88
|
-
eventHandler: new EventHandler(this),
|
|
89
|
-
inhibitorHandler: new InhibitorHandler(this),
|
|
90
|
-
integrationHandler: new IntegrationHandler(this),
|
|
91
|
-
extensionHandler: new ExtensionHandler(this),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
async connect(token) {
|
|
95
|
-
if (this.settings.debug) new XernerxLog(this).debug(`Connecting to discord using token ${token}...`);
|
|
96
|
-
const login = await this.login(token).catch(() => {
|
|
97
|
-
new XernerxLog(this).error('An invalid token was provided. Please make sure to provide a valid Discord bot token.');
|
|
98
|
-
});
|
|
99
|
-
if (this.settings.debug) new XernerxLog(this).debug(`Connected to discord using token ${token}`);
|
|
100
|
-
deploy(this);
|
|
101
|
-
new XernerxLog(this).ready();
|
|
102
|
-
const spinner = clack.spinner();
|
|
103
|
-
spinner.start();
|
|
104
|
-
return login;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { ShardingManager, ShardingManagerOptions, ClientUser } from 'discord.js';
|
|
3
|
-
interface XernerxOptions {
|
|
4
|
-
log?: {
|
|
5
|
-
info?: boolean;
|
|
6
|
-
};
|
|
7
|
-
timeout?: number;
|
|
8
|
-
}
|
|
9
|
-
export default class XernerxShardClient extends ShardingManager {
|
|
10
|
-
readonly stats: {
|
|
11
|
-
guildCount: number;
|
|
12
|
-
userCount: number;
|
|
13
|
-
shardCount: number;
|
|
14
|
-
voteCount: number;
|
|
15
|
-
shards: {};
|
|
16
|
-
};
|
|
17
|
-
user: ClientUser | null;
|
|
18
|
-
spawner: Promise<import('discord.js').Collection<number, import('discord.js').Shard>>;
|
|
19
|
-
constructor(file: string, discordOptions: ShardingManagerOptions, xernerxOptions?: XernerxOptions, data?: unknown);
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { ShardingManager } from 'discord.js';
|
|
3
|
-
import { Style } from 'dumfunctions';
|
|
4
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
5
|
-
export default class XernerxShardClient extends ShardingManager {
|
|
6
|
-
constructor(file, discordOptions, xernerxOptions, data = {}) {
|
|
7
|
-
super(file, discordOptions);
|
|
8
|
-
this.stats = { guildCount: 0, userCount: 0, shardCount: 0, voteCount: 0, shards: {} };
|
|
9
|
-
this.user = null;
|
|
10
|
-
new XernerxLog(true).info('Starting sharding process...');
|
|
11
|
-
this.on('shardCreate', async (shard) => {
|
|
12
|
-
shard
|
|
13
|
-
.on('ready', async () => {
|
|
14
|
-
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
15
|
-
const stats = await shard.fetchClientValue('stats');
|
|
16
|
-
this.stats.shards[String(shard.id)] = stats;
|
|
17
|
-
this.user = await shard.fetchClientValue('user');
|
|
18
|
-
this.stats.guildCount += stats.guildCount;
|
|
19
|
-
this.stats.userCount += stats.userCount;
|
|
20
|
-
this.stats.shardCount++;
|
|
21
|
-
this.stats.voteCount = stats.voteCount;
|
|
22
|
-
shard.send({ type: 'xernerx', data: { shardId: shard.id, sharded: true } });
|
|
23
|
-
shard.send({ type: 'client', data });
|
|
24
|
-
new XernerxLog({ settings: xernerxOptions }).info(
|
|
25
|
-
`Launched shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(this.user?.tag, { color: Style.TextColor.Blue })}! ${
|
|
26
|
-
xernerxOptions?.timeout ? `Automatically killing in ${Style.log(String(xernerxOptions.timeout), { color: Style.TextColor.Cyan })}ms.` : ''
|
|
27
|
-
}`
|
|
28
|
-
);
|
|
29
|
-
})
|
|
30
|
-
.on('error', (error) => {
|
|
31
|
-
new XernerxLog({ settings: xernerxOptions }).info(
|
|
32
|
-
`An error occurred in ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} for ${Style.log(String(this.user?.tag), { color: Style.TextColor.Blue })}! ${error}`
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
if (xernerxOptions?.timeout)
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
new XernerxLog({ settings: xernerxOptions }).warn(
|
|
38
|
-
`Automatically killing shard ${Style.log(String(shard.id), { color: Style.TextColor.Cyan })} on ${Style.log(String(shard.manager.user?.tag), {
|
|
39
|
-
color: Style.TextColor.Blue,
|
|
40
|
-
})}!`
|
|
41
|
-
);
|
|
42
|
-
shard.kill();
|
|
43
|
-
}, xernerxOptions.timeout);
|
|
44
|
-
});
|
|
45
|
-
const spawn = this.spawn();
|
|
46
|
-
this.spawner = spawn;
|
|
47
|
-
spawn.then(async (shards) => {
|
|
48
|
-
const collector = setInterval(() => {
|
|
49
|
-
const index = shards.size - 1;
|
|
50
|
-
if (shards.get(index)?.ready) {
|
|
51
|
-
clearInterval(collector);
|
|
52
|
-
new XernerxLog({ settings: xernerxOptions }).info(
|
|
53
|
-
`All Shards launched for ${Style.log(String(this.user?.tag), {
|
|
54
|
-
color: Style.TextColor.Blue,
|
|
55
|
-
})} with a total of ${Style.log(String(this.stats.shardCount), { color: Style.TextColor.Cyan })} shard${this.stats.shardCount > 1 ? 's' : ''}, watching ${Style.log(
|
|
56
|
-
String(this.stats.guildCount),
|
|
57
|
-
{
|
|
58
|
-
color: Style.TextColor.Cyan,
|
|
59
|
-
}
|
|
60
|
-
)} guild${this.stats.guildCount > 1 ? 's' : ''}, and ${Style.log(String(this.stats.userCount), { color: Style.TextColor.Cyan })} user${this.stats.userCount > 1 ? 's' : ''}!`
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
}, 1000);
|
|
64
|
-
});
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
}
|
package/dist/functions/deploy.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { GatewayVersion, REST, Routes } from 'discord.js';
|
|
3
|
-
import { Style } from 'dumfunctions';
|
|
4
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
5
|
-
import XernerxError from '../tools/XernerxError.js';
|
|
6
|
-
const globalCommands = [];
|
|
7
|
-
const localCommands = [];
|
|
8
|
-
export default function deploy(client) {
|
|
9
|
-
const commands = [];
|
|
10
|
-
function stats() {
|
|
11
|
-
client.stats.guildCount = client.guilds.cache.size;
|
|
12
|
-
client.stats.userCount = client.guilds.cache.map((g) => g.memberCount || g.approximateMemberCount || 0).reduce((a, b) => (a += b), 0);
|
|
13
|
-
}
|
|
14
|
-
process.on('message', (message) => {
|
|
15
|
-
if (message.type == 'xernerx') client.stats.shardId = message?.data?.shardId;
|
|
16
|
-
if (message.type == 'client') client.data = message.data;
|
|
17
|
-
});
|
|
18
|
-
client.on('messageCreate', stats);
|
|
19
|
-
client.on('interactionCreate', stats);
|
|
20
|
-
client.once('ready', (client) => {
|
|
21
|
-
stats();
|
|
22
|
-
client.commands.slash.map((command) => commands.push(command));
|
|
23
|
-
client.commands.context.map((command) => commands.push(command));
|
|
24
|
-
client.commands.message.map((command) => commands.push(command));
|
|
25
|
-
if (client.commands.slash.size) client.commands.slash.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
|
|
26
|
-
if (client.commands.context.size) client.commands.context.map((command) => (command.global ? globalCommands.push(command.data.toJSON()) : localCommands.push(command.data.toJSON())));
|
|
27
|
-
if (!globalCommands.length && !localCommands.length && !client.commands.message.size) return;
|
|
28
|
-
try {
|
|
29
|
-
if (client.settings.global) {
|
|
30
|
-
put(client, client.settings.global, globalCommands);
|
|
31
|
-
put(client, !client.settings.global, localCommands);
|
|
32
|
-
} else {
|
|
33
|
-
put(client, !client.settings.global, [...globalCommands, ...localCommands]);
|
|
34
|
-
put(client, client.settings.global, []);
|
|
35
|
-
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
new XernerxLog(client).error(`An error occurred while deploying the commands!`, error);
|
|
38
|
-
} finally {
|
|
39
|
-
new XernerxLog(client).info(
|
|
40
|
-
`Deployed ${Style.log(String(commands.filter((command) => command.global).length), {
|
|
41
|
-
color: Style.TextColor.Cyan,
|
|
42
|
-
})} Commands ${
|
|
43
|
-
client.settings.global
|
|
44
|
-
? Style.log('globally', { color: Style.TextColor.Green })
|
|
45
|
-
: `${Style.log('locally', { color: Style.TextColor.Red })} in ${Style.log(client.guilds.cache.get(client.settings.local)?.name, { color: Style.TextColor.Blue })}`
|
|
46
|
-
}.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function put(client, global, body) {
|
|
52
|
-
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
53
|
-
if (!global && !client.settings?.local) throw new XernerxError(`No guild ID provided as local guild!`);
|
|
54
|
-
if (!global && client.settings?.local) return rest.put(Routes.applicationGuildCommands(client.user?.id, client.settings.local), { body });
|
|
55
|
-
else return rest.put(Routes.applicationCommands(client.user?.id), { body });
|
|
56
|
-
}
|
package/dist/functions/load.d.ts
DELETED
package/dist/functions/load.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import XernerxLog from '../tools/XernerxLog.js';
|
|
3
|
-
export default async function load(client, path, type) {
|
|
4
|
-
try {
|
|
5
|
-
let file = new (await import(`file://${path}`)).default();
|
|
6
|
-
file.filetype = type;
|
|
7
|
-
file.filepath = path;
|
|
8
|
-
file.client = client;
|
|
9
|
-
file.util = {};
|
|
10
|
-
fileSave(client, file, type);
|
|
11
|
-
return file;
|
|
12
|
-
} catch (error) {
|
|
13
|
-
new XernerxLog(client).error(`Couldn't load ${type} ${path.match(/\w*\.js$/gim)?.at(0) || path}`, error);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function fileSave(client, file, type) {
|
|
17
|
-
switch (type) {
|
|
18
|
-
case 'MessageCommand':
|
|
19
|
-
client.commands.message.set(file.name, file);
|
|
20
|
-
break;
|
|
21
|
-
case 'SlashCommand':
|
|
22
|
-
client.commands.slash.set(file.name, file);
|
|
23
|
-
break;
|
|
24
|
-
case 'ContextCommand':
|
|
25
|
-
client.commands.context.set(file.name, file);
|
|
26
|
-
break;
|
|
27
|
-
case 'Inhibitor':
|
|
28
|
-
client.inhibitors.set(file.name, file);
|
|
29
|
-
break;
|
|
30
|
-
case 'Event':
|
|
31
|
-
client.events.set(file.name, file);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/dist/functions/reload.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import load from './load.js';
|
|
5
|
-
export default async function reload(client, type) {
|
|
6
|
-
switch (type) {
|
|
7
|
-
case 'message': {
|
|
8
|
-
client.commands.message.clear();
|
|
9
|
-
if (!client.modules.options.message) return null;
|
|
10
|
-
const directory = path.resolve(client.modules.options.message?.directory);
|
|
11
|
-
for (const file of fs.readdirSync(directory)) {
|
|
12
|
-
load(client, `${directory}\\${file}`, 'MessageCommand');
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
case 'slash': {
|
|
17
|
-
return client.commands.slash.clear();
|
|
18
|
-
}
|
|
19
|
-
case 'context': {
|
|
20
|
-
return client.commands.context.clear();
|
|
21
|
-
}
|
|
22
|
-
case 'events': {
|
|
23
|
-
return client.events.clear();
|
|
24
|
-
}
|
|
25
|
-
case 'inhibitors': {
|
|
26
|
-
return client.inhibitors.clear();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { ActivityType } from 'discord.js';
|
|
3
|
-
import { Style } from 'dumfunctions';
|
|
4
|
-
export default function setPresence(client, options) {
|
|
5
|
-
const presence = () =>
|
|
6
|
-
client.user?.setPresence({
|
|
7
|
-
activities: [
|
|
8
|
-
{
|
|
9
|
-
name: options.text,
|
|
10
|
-
type: ActivityType[Style.titleCase(options.type || 'Custom')],
|
|
11
|
-
url: options.url,
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
status: options.status,
|
|
15
|
-
});
|
|
16
|
-
let response = presence();
|
|
17
|
-
if (options.interval)
|
|
18
|
-
setInterval(() => {
|
|
19
|
-
response = presence();
|
|
20
|
-
}, options.interval);
|
|
21
|
-
return response;
|
|
22
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
import { XernerxMessage, XernerxSlashInteraction, XernerxUser, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
4
|
-
export declare function xernerxUser(event: XernerxMessage | XernerxSlashInteraction | XernerxUserContextInteraction | XernerxUserContextInteraction, client: XernerxClient): Promise<XernerxUser>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export async function xernerxUser(event, client) {
|
|
3
|
-
const author = event.author || event.user;
|
|
4
|
-
author.owner = isOwner(client, author);
|
|
5
|
-
if (client.dbl.validate) author.voted = await client?.dbl?.validate(author);
|
|
6
|
-
return author;
|
|
7
|
-
}
|
|
8
|
-
function isOwner(client, user) {
|
|
9
|
-
return client.settings.ownerId.includes(user.id);
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
3
|
-
import { ContextHandlerOptions, MessageHandlerOptions, SlashHandlerOptions } from '../types/interfaces.js';
|
|
4
|
-
import Handler from './Handler.js';
|
|
5
|
-
export default class CommandHandler extends Handler {
|
|
6
|
-
readonly readyTimestamp: number;
|
|
7
|
-
constructor(client: XernerxClient);
|
|
8
|
-
loadMessageCommands(options: MessageHandlerOptions): Promise<void>;
|
|
9
|
-
loadSlashCommands(options: SlashHandlerOptions): Promise<void>;
|
|
10
|
-
loadContextCommands(options: ContextHandlerOptions): Promise<void>;
|
|
11
|
-
private messageCommandRun;
|
|
12
|
-
private slashCommandRun;
|
|
13
|
-
private contextCommandRun;
|
|
14
|
-
private exec;
|
|
15
|
-
private _checks;
|
|
16
|
-
}
|