vimcord 1.0.22 → 1.0.24
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/index.cjs +234 -186
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +77 -54
- package/dist/index.d.ts +77 -54
- package/dist/index.js +228 -181
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -92,18 +92,8 @@ function validateCommandPermissions(permissions, client, user, command) {
|
|
|
92
92
|
return { validated: false, failReason: 7 /* NotBotOwner */ };
|
|
93
93
|
}
|
|
94
94
|
if (__existsAndTrue(permissions.botStaffOnly)) {
|
|
95
|
-
if (
|
|
96
|
-
return { validated:
|
|
97
|
-
}
|
|
98
|
-
if (inGuild) {
|
|
99
|
-
for (const [k, role] of user.roles.cache) {
|
|
100
|
-
if (!user.roles.cache.has(role.id)) {
|
|
101
|
-
missingRoles.push(role.id);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (missingRoles.length) {
|
|
105
|
-
return { validated: false, failReason: 8 /* NotBotStaff */, missingRoles };
|
|
106
|
-
}
|
|
95
|
+
if (client.config.staff.ownerId === user.id || client.config.staff.superUsers.includes(user.id)) {
|
|
96
|
+
return { validated: true };
|
|
107
97
|
}
|
|
108
98
|
if (command instanceof BaseInteraction && command.isCommand()) {
|
|
109
99
|
let commandName = null;
|
|
@@ -113,17 +103,30 @@ function validateCommandPermissions(permissions, client, user, command) {
|
|
|
113
103
|
} else {
|
|
114
104
|
commandName = command.commandName;
|
|
115
105
|
}
|
|
116
|
-
if (
|
|
106
|
+
if (client.config.staff.bypassers.some(
|
|
117
107
|
(bypass) => bypass.commandName.toLowerCase() === commandName.toLowerCase() && bypass.userIds.includes(user.id)
|
|
118
108
|
)) {
|
|
119
|
-
return { validated:
|
|
109
|
+
return { validated: true };
|
|
120
110
|
}
|
|
121
111
|
}
|
|
122
|
-
if (typeof command === "string" &&
|
|
112
|
+
if (typeof command === "string" && client.config.staff.bypassers.some(
|
|
123
113
|
(bypass) => bypass.commandName.toLowerCase() === command.toLowerCase() && bypass.userIds.includes(user.id)
|
|
124
114
|
)) {
|
|
125
|
-
return { validated:
|
|
115
|
+
return { validated: true };
|
|
126
116
|
}
|
|
117
|
+
if (inGuild) {
|
|
118
|
+
for (const role of user.roles.cache.values()) {
|
|
119
|
+
if (!user.roles.cache.has(role.id)) {
|
|
120
|
+
missingRoles.push(role.id);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (missingRoles.length) {
|
|
124
|
+
return { validated: false, failReason: 8 /* NotBotStaff */, missingRoles };
|
|
125
|
+
} else {
|
|
126
|
+
return { validated: true };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { validated: false, failReason: 8 /* NotBotStaff */ };
|
|
127
130
|
}
|
|
128
131
|
return { validated: true };
|
|
129
132
|
}
|
|
@@ -428,12 +431,12 @@ function getProcessDir() {
|
|
|
428
431
|
if (!mainPath) return "";
|
|
429
432
|
return path.dirname(mainPath);
|
|
430
433
|
}
|
|
431
|
-
async function importModulesFromDir(dir,
|
|
434
|
+
async function importModulesFromDir(dir, suffix) {
|
|
432
435
|
const cwd = getProcessDir();
|
|
433
436
|
const MODULE_RELATIVE_PATH = path.join(cwd, dir);
|
|
434
437
|
const MODULE_LOG_PATH = dir;
|
|
435
438
|
const files = $.fs.readDir(MODULE_RELATIVE_PATH).filter(
|
|
436
|
-
(fn) => fn.endsWith(`${
|
|
439
|
+
(fn) => fn.endsWith(`${suffix ? `.${suffix}` : ""}.js`) || fn.endsWith(`${suffix ? `.${suffix}` : ""}.ts`)
|
|
437
440
|
);
|
|
438
441
|
if (!files.length) {
|
|
439
442
|
return [];
|
|
@@ -663,8 +666,9 @@ var EventBuilder = class _EventBuilder {
|
|
|
663
666
|
|
|
664
667
|
// src/builders/prefixCommand.builder.ts
|
|
665
668
|
var PrefixCommandBuilder = class extends BaseCommandBuilder {
|
|
666
|
-
constructor(
|
|
667
|
-
super(1 /* Prefix */,
|
|
669
|
+
constructor(options) {
|
|
670
|
+
super(1 /* Prefix */, options);
|
|
671
|
+
this.options = options;
|
|
668
672
|
const originalExecute = this.options.execute;
|
|
669
673
|
this.options.execute = async (client, message) => {
|
|
670
674
|
return await this.handleExecution(client, message, originalExecute);
|
|
@@ -871,7 +875,13 @@ var defaultConfig = {
|
|
|
871
875
|
name: "Discord Bot",
|
|
872
876
|
appVersion: "1.0.0",
|
|
873
877
|
verbose: false,
|
|
874
|
-
disableBanner: false
|
|
878
|
+
disableBanner: false,
|
|
879
|
+
moduleSuffixes: {
|
|
880
|
+
slashCommand: "slash",
|
|
881
|
+
contextCommand: "ctx",
|
|
882
|
+
prefixCommand: "prefix",
|
|
883
|
+
event: "event"
|
|
884
|
+
}
|
|
875
885
|
};
|
|
876
886
|
function createVimcordAppConfig(options = {}) {
|
|
877
887
|
return _6.merge(defaultConfig, options);
|
|
@@ -1240,7 +1250,7 @@ function formatThousands(num, sep = ",") {
|
|
|
1240
1250
|
// src/modules/status.manager.ts
|
|
1241
1251
|
import EventEmitter from "events";
|
|
1242
1252
|
import { $ as $2 } from "qznt";
|
|
1243
|
-
var
|
|
1253
|
+
var StatusManager = class {
|
|
1244
1254
|
client;
|
|
1245
1255
|
logger;
|
|
1246
1256
|
emitter = new EventEmitter();
|
|
@@ -1361,192 +1371,232 @@ var VimcordStatusManager = class {
|
|
|
1361
1371
|
};
|
|
1362
1372
|
|
|
1363
1373
|
// src/modules/command.manager.ts
|
|
1364
|
-
import {
|
|
1365
|
-
var
|
|
1366
|
-
|
|
1374
|
+
import { Routes } from "discord.js";
|
|
1375
|
+
var BaseCommandManager = class {
|
|
1376
|
+
type;
|
|
1377
|
+
client;
|
|
1378
|
+
commands = /* @__PURE__ */ new Map();
|
|
1379
|
+
moduleSuffix;
|
|
1380
|
+
constructor(client, type, moduleSuffix) {
|
|
1381
|
+
this.type = type;
|
|
1367
1382
|
this.client = client;
|
|
1368
|
-
this.
|
|
1369
|
-
this.client.whenReady().then((c) => this.rest = new REST().setToken(c.token));
|
|
1383
|
+
this.moduleSuffix = moduleSuffix;
|
|
1370
1384
|
}
|
|
1371
|
-
|
|
1372
|
-
|
|
1385
|
+
/**
|
|
1386
|
+
* Gets a command by name.
|
|
1387
|
+
*/
|
|
1373
1388
|
get(name) {
|
|
1374
|
-
|
|
1389
|
+
if (this.type === 1 /* Prefix */) {
|
|
1390
|
+
const config = this.client.config.prefixCommands;
|
|
1391
|
+
const search = config.allowCaseInsensitiveCommandNames ? name.toLowerCase() : name;
|
|
1392
|
+
return Array.from(this.commands.values()).find((cmd) => {
|
|
1393
|
+
const commandName = "builder" in cmd ? cmd.builder.name : cmd.options.name;
|
|
1394
|
+
const trigger = config.allowCaseInsensitiveCommandNames ? commandName.toLowerCase() : commandName;
|
|
1395
|
+
if (trigger === search) return true;
|
|
1396
|
+
if ("aliases" in cmd.options) {
|
|
1397
|
+
return cmd.options.aliases?.some(
|
|
1398
|
+
(a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
} else {
|
|
1403
|
+
return this.commands.get(name);
|
|
1404
|
+
}
|
|
1375
1405
|
}
|
|
1376
1406
|
/**
|
|
1377
|
-
*
|
|
1407
|
+
* Gets/filters commands and orders them alphabetically
|
|
1378
1408
|
*/
|
|
1379
|
-
getAll(options) {
|
|
1409
|
+
getAll(options = {}) {
|
|
1380
1410
|
const matchedCommands = /* @__PURE__ */ new Map();
|
|
1381
1411
|
const isDev = this.client.config.app.devMode;
|
|
1382
1412
|
for (const cmd of this.commands.values()) {
|
|
1383
|
-
const
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const nameMatched = options.names?.includes(name) || options.fuzzyNames?.some((fuzzy) => name.includes(fuzzy));
|
|
1413
|
+
const commandName = "builder" in cmd ? cmd.builder.name : cmd.options.name;
|
|
1414
|
+
if (options.names || options.fuzzyNames) {
|
|
1415
|
+
const nameMatched = options.names?.includes(commandName) || options.fuzzyNames?.some((fuzzy) => commandName.includes(fuzzy));
|
|
1387
1416
|
if (!nameMatched) continue;
|
|
1388
1417
|
}
|
|
1389
|
-
if (options
|
|
1390
|
-
matchedCommands.set(
|
|
1418
|
+
if (options.ignoreDeploymentOptions) {
|
|
1419
|
+
matchedCommands.set(commandName, cmd);
|
|
1391
1420
|
continue;
|
|
1392
1421
|
}
|
|
1393
|
-
const deployment =
|
|
1422
|
+
const deployment = "deployment" in cmd.options ? cmd.options.deployment ?? {} : {};
|
|
1394
1423
|
const isProperEnv = !deployment.environments || deployment.environments.includes(isDev ? "development" : "production");
|
|
1395
1424
|
if (!isProperEnv) continue;
|
|
1396
|
-
if (options
|
|
1397
|
-
matchedCommands.set(
|
|
1425
|
+
if (options.globalOnly && deployment.global === false) continue;
|
|
1426
|
+
matchedCommands.set(commandName, cmd);
|
|
1427
|
+
}
|
|
1428
|
+
return Array.from(matchedCommands.values()).sort((a, b) => {
|
|
1429
|
+
const commandNameA = "builder" in a ? a.builder.name : a.options.name;
|
|
1430
|
+
const commandNameB = "builder" in b ? b.builder.name : b.options.name;
|
|
1431
|
+
return commandNameA.localeCompare(commandNameB);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Groups commands by category alphabetically.
|
|
1436
|
+
*/
|
|
1437
|
+
sortByCategory() {
|
|
1438
|
+
const categories = /* @__PURE__ */ new Map();
|
|
1439
|
+
for (const cmd of this.commands.values()) {
|
|
1440
|
+
const metadata = cmd.options.metadata;
|
|
1441
|
+
if (!metadata?.category) continue;
|
|
1442
|
+
let entry = categories.get(metadata.category);
|
|
1443
|
+
if (!entry) {
|
|
1444
|
+
entry = {
|
|
1445
|
+
name: metadata.category,
|
|
1446
|
+
emoji: metadata.categoryEmoji,
|
|
1447
|
+
commands: []
|
|
1448
|
+
};
|
|
1449
|
+
categories.set(metadata.category, entry);
|
|
1450
|
+
}
|
|
1451
|
+
entry.commands.push(cmd);
|
|
1398
1452
|
}
|
|
1399
|
-
return
|
|
1453
|
+
return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
|
|
1454
|
+
cat.commands.sort((a, b) => {
|
|
1455
|
+
const commandNameA = "builder" in a ? a.builder.name : a.options.name;
|
|
1456
|
+
const commandNameB = "builder" in b ? b.builder.name : b.options.name;
|
|
1457
|
+
return commandNameA.localeCompare(commandNameB);
|
|
1458
|
+
});
|
|
1459
|
+
return cat;
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Imports command modules from a directory.
|
|
1464
|
+
* @param dir Path of one or more folders.
|
|
1465
|
+
* @param set Replaces imported command modules with the ones found.
|
|
1466
|
+
*/
|
|
1467
|
+
async importFrom(dir, set = false) {
|
|
1468
|
+
if (set) this.commands.clear();
|
|
1469
|
+
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1470
|
+
const modules = [];
|
|
1471
|
+
for (const _dir of dirs) {
|
|
1472
|
+
const results = await importModulesFromDir(_dir, this.moduleSuffix);
|
|
1473
|
+
modules.push(...results.map(({ module }) => module.default));
|
|
1474
|
+
}
|
|
1475
|
+
for (const module of modules) {
|
|
1476
|
+
const commandName = "builder" in module ? module.builder.name : module.options.name;
|
|
1477
|
+
this.commands.set(commandName, module);
|
|
1478
|
+
}
|
|
1479
|
+
let moduleType;
|
|
1480
|
+
switch (this.type) {
|
|
1481
|
+
case 0 /* Slash */:
|
|
1482
|
+
moduleType = "Prefix Commands";
|
|
1483
|
+
break;
|
|
1484
|
+
case 2 /* Context */:
|
|
1485
|
+
moduleType = "Context Commands";
|
|
1486
|
+
break;
|
|
1487
|
+
case 1 /* Prefix */:
|
|
1488
|
+
moduleType = "Prefix Commands";
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
this.client.logger.moduleLoaded(moduleType, modules.length);
|
|
1492
|
+
return this.commands;
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
var SlashCommandManager = class extends BaseCommandManager {
|
|
1496
|
+
constructor(client) {
|
|
1497
|
+
super(client, 0 /* Slash */, client.config.app.moduleSuffixes.slashCommand);
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
var ContextCommandManager = class extends BaseCommandManager {
|
|
1501
|
+
constructor(client) {
|
|
1502
|
+
super(client, 2 /* Context */, client.config.app.moduleSuffixes.contextCommand);
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
var PrefixCommandManager = class extends BaseCommandManager {
|
|
1506
|
+
constructor(client) {
|
|
1507
|
+
super(client, 1 /* Prefix */, client.config.app.moduleSuffixes.prefixCommand);
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
var CommandManager = class {
|
|
1511
|
+
client;
|
|
1512
|
+
slash;
|
|
1513
|
+
prefix;
|
|
1514
|
+
context;
|
|
1515
|
+
constructor(client) {
|
|
1516
|
+
this.client = client;
|
|
1517
|
+
this.slash = new SlashCommandManager(client);
|
|
1518
|
+
this.prefix = new PrefixCommandManager(client);
|
|
1519
|
+
this.context = new ContextCommandManager(client);
|
|
1520
|
+
}
|
|
1521
|
+
getAllAppCommands(options = {}) {
|
|
1522
|
+
return [...this.slash.getAll(options), ...this.context.getAll(options)];
|
|
1400
1523
|
}
|
|
1401
|
-
async registerGlobal(options) {
|
|
1524
|
+
async registerGlobal(options = {}) {
|
|
1402
1525
|
const client = await this.client.whenReady();
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}).values()
|
|
1409
|
-
).map((cmd) => cmd.builder.toJSON());
|
|
1526
|
+
if (!client.rest) {
|
|
1527
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands globally: REST is not initialized`);
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
const commands = this.getAllAppCommands(options);
|
|
1410
1531
|
if (!commands.length) {
|
|
1411
|
-
console.log(
|
|
1532
|
+
console.log("[CommandManager] No commands to register globally");
|
|
1412
1533
|
return;
|
|
1413
1534
|
}
|
|
1414
|
-
console.log(`[
|
|
1535
|
+
console.log(`[CommandManager] Registering (${commands.length}) commands globally...`);
|
|
1415
1536
|
try {
|
|
1416
|
-
await
|
|
1417
|
-
console.log(`[
|
|
1537
|
+
await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands });
|
|
1538
|
+
console.log(`[CommandManager] \u2714 Registered app commands globally`);
|
|
1418
1539
|
} catch (err) {
|
|
1419
|
-
console.
|
|
1540
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands globally`, err);
|
|
1420
1541
|
}
|
|
1421
1542
|
}
|
|
1422
|
-
async
|
|
1543
|
+
async unregisterGlobal() {
|
|
1423
1544
|
const client = await this.client.whenReady();
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1545
|
+
if (!client.rest) {
|
|
1546
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally: REST is not initialized`);
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
try {
|
|
1550
|
+
await client.rest.put(Routes.applicationCommands(client.user.id), { body: [] });
|
|
1551
|
+
console.log(`[CommandManager] \u2714 Removed app commands globally`);
|
|
1552
|
+
} catch (err) {
|
|
1553
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally`, err);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
async registerGuild(options = {}) {
|
|
1557
|
+
const client = await this.client.whenReady();
|
|
1558
|
+
if (!client.rest) {
|
|
1559
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
const commands = this.getAllAppCommands(options);
|
|
1430
1563
|
if (!commands.length) {
|
|
1431
|
-
console.log(
|
|
1564
|
+
console.log("[CommandManager] No commands to register by guild");
|
|
1432
1565
|
return;
|
|
1433
1566
|
}
|
|
1434
|
-
const guildIds = options
|
|
1435
|
-
console.log(`[
|
|
1567
|
+
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
1568
|
+
console.log(`[CommandManager] Registering (${commands.length}) commands for ${guildIds.length} guilds...`);
|
|
1436
1569
|
await Promise.all(
|
|
1437
1570
|
guildIds.map(
|
|
1438
|
-
(guildId) =>
|
|
1571
|
+
(guildId) => client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
|
|
1439
1572
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
1440
|
-
console.log(`[
|
|
1573
|
+
console.log(`[CommandManager] \u2714 Set app commands in guild: ${guildId} (${gName})`);
|
|
1441
1574
|
}).catch((err) => {
|
|
1442
1575
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
1443
|
-
console.log(`[
|
|
1576
|
+
console.log(`[CommandManager] \u2716 Failed to set app commands in guild: ${guildId} (${gName})`, err);
|
|
1444
1577
|
})
|
|
1445
1578
|
)
|
|
1446
1579
|
);
|
|
1447
1580
|
}
|
|
1448
|
-
async unregisterGuild(options) {
|
|
1581
|
+
async unregisterGuild(options = {}) {
|
|
1449
1582
|
const client = await this.client.whenReady();
|
|
1450
|
-
|
|
1451
|
-
|
|
1583
|
+
if (!client.rest) {
|
|
1584
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
1588
|
+
console.log(`[CommandManager] Unregistering commands from ${guildIds.length} guilds...`);
|
|
1452
1589
|
await Promise.all(
|
|
1453
1590
|
guildIds.map(
|
|
1454
|
-
(guildId) =>
|
|
1455
|
-
(err) => console.log(`[${this.typeName}] \u2716 Failed to remove app commands in guild: ${guildId}`, err)
|
|
1456
|
-
)
|
|
1591
|
+
(guildId) => client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: [] }).then(() => console.log(`[CommandManager] \u2714 Removed app commands in guild: ${guildId}`)).catch((err) => console.log(`[CommandManager] \u2716 Failed to remove app commands in guild: ${guildId}`, err))
|
|
1457
1592
|
)
|
|
1458
1593
|
);
|
|
1459
1594
|
}
|
|
1460
|
-
async unregisterGlobal() {
|
|
1461
|
-
const client = await this.client.whenReady();
|
|
1462
|
-
try {
|
|
1463
|
-
await this.rest.put(Routes.applicationCommands(client.user.id), { body: [] });
|
|
1464
|
-
console.log(`[${this.typeName}] \u2714 Removed app commands globally`);
|
|
1465
|
-
} catch (err) {
|
|
1466
|
-
console.log(`[${this.typeName}] \u2716 Failed to remove app commands globally`, err);
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
};
|
|
1470
|
-
var VimcordSlashCommandManager = class extends VimcordAppCommandManager {
|
|
1471
|
-
constructor(client) {
|
|
1472
|
-
super(client, "SlashCommandManager");
|
|
1473
|
-
}
|
|
1474
|
-
async importFrom(dir, replaceAll = false) {
|
|
1475
|
-
if (replaceAll) this.commands.clear();
|
|
1476
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1477
|
-
const modules = (await Promise.all(
|
|
1478
|
-
dirs.map((d) => importModulesFromDir(d, "slash"))
|
|
1479
|
-
)).flat();
|
|
1480
|
-
for (const { module } of modules) {
|
|
1481
|
-
this.commands.set(module.default.builder.name, module.default);
|
|
1482
|
-
}
|
|
1483
|
-
this.client.logger.moduleLoaded("Slash Commands", modules.length);
|
|
1484
|
-
return this.commands;
|
|
1485
|
-
}
|
|
1486
|
-
};
|
|
1487
|
-
var VimcordContextCommandManager = class extends VimcordAppCommandManager {
|
|
1488
|
-
constructor(client) {
|
|
1489
|
-
super(client, "ContextCommandManager");
|
|
1490
|
-
}
|
|
1491
|
-
async importFrom(dir, replaceAll = false) {
|
|
1492
|
-
if (replaceAll) this.commands.clear();
|
|
1493
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1494
|
-
const modules = (await Promise.all(
|
|
1495
|
-
dirs.map((d) => importModulesFromDir(d, "ctx"))
|
|
1496
|
-
)).flat();
|
|
1497
|
-
for (const { module } of modules) {
|
|
1498
|
-
this.commands.set(module.default.builder.name, module.default);
|
|
1499
|
-
}
|
|
1500
|
-
this.client.logger.moduleLoaded("Context Commands", modules.length);
|
|
1501
|
-
return this.commands;
|
|
1502
|
-
}
|
|
1503
|
-
};
|
|
1504
|
-
var VimcordPrefixCommandManager = class {
|
|
1505
|
-
constructor(client) {
|
|
1506
|
-
this.client = client;
|
|
1507
|
-
}
|
|
1508
|
-
commands = /* @__PURE__ */ new Map();
|
|
1509
|
-
resolve(trigger) {
|
|
1510
|
-
const config = this.client.config.prefixCommands;
|
|
1511
|
-
const search = config.allowCaseInsensitiveCommandNames ? trigger.toLowerCase() : trigger;
|
|
1512
|
-
return Array.from(this.commands.values()).find((cmd) => {
|
|
1513
|
-
const opts = cmd.toConfig();
|
|
1514
|
-
const name = config.allowCaseInsensitiveCommandNames ? opts.name.toLowerCase() : opts.name;
|
|
1515
|
-
if (name === search) return true;
|
|
1516
|
-
return opts.aliases?.some(
|
|
1517
|
-
(a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
|
|
1518
|
-
);
|
|
1519
|
-
});
|
|
1520
|
-
}
|
|
1521
|
-
async importFrom(dir, replaceAll = false) {
|
|
1522
|
-
if (replaceAll) this.commands.clear();
|
|
1523
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1524
|
-
const modules = (await Promise.all(
|
|
1525
|
-
dirs.map(
|
|
1526
|
-
(d) => importModulesFromDir(d, "prefix")
|
|
1527
|
-
)
|
|
1528
|
-
)).flat();
|
|
1529
|
-
for (const { module } of modules) {
|
|
1530
|
-
this.commands.set(module.default.toConfig().name, module.default);
|
|
1531
|
-
}
|
|
1532
|
-
this.client.logger.moduleLoaded("Prefix Commands", modules.length);
|
|
1533
|
-
return this.commands;
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
var VimcordCommandManager = class {
|
|
1537
|
-
slash;
|
|
1538
|
-
prefix;
|
|
1539
|
-
context;
|
|
1540
|
-
constructor(client) {
|
|
1541
|
-
this.slash = new VimcordSlashCommandManager(client);
|
|
1542
|
-
this.prefix = new VimcordPrefixCommandManager(client);
|
|
1543
|
-
this.context = new VimcordContextCommandManager(client);
|
|
1544
|
-
}
|
|
1545
1595
|
};
|
|
1546
1596
|
|
|
1547
1597
|
// src/modules/event.manager.ts
|
|
1548
1598
|
import { Events } from "discord.js";
|
|
1549
|
-
var
|
|
1599
|
+
var EventManager = class {
|
|
1550
1600
|
client;
|
|
1551
1601
|
events = /* @__PURE__ */ new Map();
|
|
1552
1602
|
logger;
|
|
@@ -2129,7 +2179,7 @@ async function sendCommandErrorEmbed(client, error, guild, messageOrInteraction)
|
|
|
2129
2179
|
const embed_error = config?.embed?.(new BetterEmbed(), error, guild) || new BetterEmbed({
|
|
2130
2180
|
color: "Red",
|
|
2131
2181
|
title: "Something went wrong",
|
|
2132
|
-
description: "If you keep encountering this error, please report it"
|
|
2182
|
+
description: "If you keep encountering this error, please report it."
|
|
2133
2183
|
});
|
|
2134
2184
|
const msg = await embed_error.send(messageOrInteraction, {
|
|
2135
2185
|
components: [actionRow],
|
|
@@ -2175,7 +2225,7 @@ async function retryExponentialBackoff(fn, maxRetries = 3, retryDelay = 1e3) {
|
|
|
2175
2225
|
}
|
|
2176
2226
|
|
|
2177
2227
|
// package.json
|
|
2178
|
-
var version = "1.0.
|
|
2228
|
+
var version = "1.0.24";
|
|
2179
2229
|
|
|
2180
2230
|
// src/client.ts
|
|
2181
2231
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -2269,9 +2319,9 @@ var Vimcord = class _Vimcord extends Client2 {
|
|
|
2269
2319
|
prefixCommands: createVimcordPrefixCommandConfig(config.prefixCommands),
|
|
2270
2320
|
contextCommands: createVimcordContextCommandConfig(config.contextCommands)
|
|
2271
2321
|
};
|
|
2272
|
-
this.status = new
|
|
2273
|
-
this.events = new
|
|
2274
|
-
this.commands = new
|
|
2322
|
+
this.status = new StatusManager(this);
|
|
2323
|
+
this.events = new EventManager(this);
|
|
2324
|
+
this.commands = new CommandManager(this);
|
|
2275
2325
|
if (this.features.useEnv) {
|
|
2276
2326
|
if (typeof this.features.useEnv === "object") {
|
|
2277
2327
|
dotEnv.config({ quiet: true, ...this.features.useEnv });
|
|
@@ -2470,7 +2520,7 @@ var defaultPrefixCommandHandler = new EventBuilder({
|
|
|
2470
2520
|
const args = contentWithoutPrefix.split(/\s+/);
|
|
2471
2521
|
const trigger = args.shift();
|
|
2472
2522
|
if (!trigger) return;
|
|
2473
|
-
const command = client.commands.prefix.
|
|
2523
|
+
const command = client.commands.prefix.get(trigger);
|
|
2474
2524
|
if (!command) return;
|
|
2475
2525
|
message.content = args.join(" ");
|
|
2476
2526
|
try {
|
|
@@ -2790,7 +2840,7 @@ var MongoSchemaBuilder = class {
|
|
|
2790
2840
|
return this.model.findOne(filter, projection, { ...options, lean: options?.lean ?? true });
|
|
2791
2841
|
});
|
|
2792
2842
|
}
|
|
2793
|
-
async fetchAll(filter, projection, options) {
|
|
2843
|
+
async fetchAll(filter = {}, projection, options) {
|
|
2794
2844
|
return await this.execute(async () => {
|
|
2795
2845
|
return this.model.find(filter, projection, { ...options, lean: options?.lean ?? true });
|
|
2796
2846
|
}) || [];
|
|
@@ -4090,13 +4140,11 @@ CLI.addCommand("register", "Register app commands (slash & context) globally, or
|
|
|
4090
4140
|
switch (mode) {
|
|
4091
4141
|
case "guild":
|
|
4092
4142
|
CLI.logger.info("Registering guild commands...");
|
|
4093
|
-
await client.commands.
|
|
4094
|
-
await client.commands.context.registerGuild({ guilds: guildIds });
|
|
4143
|
+
await client.commands.registerGuild({ guilds: guildIds });
|
|
4095
4144
|
break;
|
|
4096
4145
|
case "global":
|
|
4097
4146
|
CLI.logger.info("Registering global commands...");
|
|
4098
|
-
await client.commands.
|
|
4099
|
-
await client.commands.context.registerGlobal();
|
|
4147
|
+
await client.commands.registerGlobal();
|
|
4100
4148
|
break;
|
|
4101
4149
|
}
|
|
4102
4150
|
});
|
|
@@ -4112,13 +4160,11 @@ CLI.addCommand("unregister", "Unregister app commands globally, or per guild", a
|
|
|
4112
4160
|
switch (mode) {
|
|
4113
4161
|
case "guild":
|
|
4114
4162
|
CLI.logger.info("Unregistering guild commands...");
|
|
4115
|
-
await client.commands.
|
|
4116
|
-
await client.commands.context.unregisterGuild({ guilds: guildIds });
|
|
4163
|
+
await client.commands.unregisterGuild({ guilds: guildIds });
|
|
4117
4164
|
break;
|
|
4118
4165
|
case "global":
|
|
4119
4166
|
CLI.logger.info("Unregistering global commands...");
|
|
4120
|
-
await client.commands.
|
|
4121
|
-
await client.commands.context.unregisterGlobal();
|
|
4167
|
+
await client.commands.unregisterGlobal();
|
|
4122
4168
|
break;
|
|
4123
4169
|
}
|
|
4124
4170
|
});
|
|
@@ -4219,16 +4265,20 @@ function pickRandom(arr, options) {
|
|
|
4219
4265
|
}
|
|
4220
4266
|
export {
|
|
4221
4267
|
BaseCommandBuilder,
|
|
4268
|
+
BaseCommandManager,
|
|
4222
4269
|
BetterCollector,
|
|
4223
4270
|
BetterContainer,
|
|
4224
4271
|
BetterEmbed,
|
|
4225
4272
|
BetterModal,
|
|
4226
4273
|
CLI,
|
|
4227
4274
|
CollectorTimeoutType,
|
|
4275
|
+
CommandManager,
|
|
4228
4276
|
CommandType,
|
|
4229
4277
|
ContextCommandBuilder,
|
|
4278
|
+
ContextCommandManager,
|
|
4230
4279
|
DynaSend,
|
|
4231
4280
|
EventBuilder,
|
|
4281
|
+
EventManager,
|
|
4232
4282
|
LOGGER_COLORS,
|
|
4233
4283
|
LogLevel,
|
|
4234
4284
|
Logger,
|
|
@@ -4239,20 +4289,17 @@ export {
|
|
|
4239
4289
|
PaginationType,
|
|
4240
4290
|
Paginator,
|
|
4241
4291
|
PrefixCommandBuilder,
|
|
4292
|
+
PrefixCommandManager,
|
|
4242
4293
|
Prompt,
|
|
4243
4294
|
PromptResolveType,
|
|
4244
4295
|
RateLimitScope,
|
|
4245
4296
|
SendMethod,
|
|
4246
4297
|
SlashCommandBuilder,
|
|
4298
|
+
SlashCommandManager,
|
|
4299
|
+
StatusManager,
|
|
4247
4300
|
StatusType,
|
|
4248
4301
|
Vimcord,
|
|
4249
4302
|
VimcordCLI,
|
|
4250
|
-
VimcordCommandManager,
|
|
4251
|
-
VimcordContextCommandManager,
|
|
4252
|
-
VimcordEventManager,
|
|
4253
|
-
VimcordPrefixCommandManager,
|
|
4254
|
-
VimcordSlashCommandManager,
|
|
4255
|
-
VimcordStatusManager,
|
|
4256
4303
|
__zero,
|
|
4257
4304
|
cleanMention,
|
|
4258
4305
|
clientInstances,
|