vimcord 1.0.23 → 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 +209 -210
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +69 -67
- package/dist/index.d.ts +69 -67
- package/dist/index.js +203 -205
- 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 };
|
|
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
|
+
}
|
|
126
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 [];
|
|
@@ -872,7 +875,13 @@ var defaultConfig = {
|
|
|
872
875
|
name: "Discord Bot",
|
|
873
876
|
appVersion: "1.0.0",
|
|
874
877
|
verbose: false,
|
|
875
|
-
disableBanner: false
|
|
878
|
+
disableBanner: false,
|
|
879
|
+
moduleSuffixes: {
|
|
880
|
+
slashCommand: "slash",
|
|
881
|
+
contextCommand: "ctx",
|
|
882
|
+
prefixCommand: "prefix",
|
|
883
|
+
event: "event"
|
|
884
|
+
}
|
|
876
885
|
};
|
|
877
886
|
function createVimcordAppConfig(options = {}) {
|
|
878
887
|
return _6.merge(defaultConfig, options);
|
|
@@ -1241,7 +1250,7 @@ function formatThousands(num, sep = ",") {
|
|
|
1241
1250
|
// src/modules/status.manager.ts
|
|
1242
1251
|
import EventEmitter from "events";
|
|
1243
1252
|
import { $ as $2 } from "qznt";
|
|
1244
|
-
var
|
|
1253
|
+
var StatusManager = class {
|
|
1245
1254
|
client;
|
|
1246
1255
|
logger;
|
|
1247
1256
|
emitter = new EventEmitter();
|
|
@@ -1362,45 +1371,68 @@ var VimcordStatusManager = class {
|
|
|
1362
1371
|
};
|
|
1363
1372
|
|
|
1364
1373
|
// src/modules/command.manager.ts
|
|
1365
|
-
import {
|
|
1366
|
-
var
|
|
1367
|
-
|
|
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;
|
|
1368
1382
|
this.client = client;
|
|
1369
|
-
this.
|
|
1370
|
-
this.client.whenReady().then((c) => this.rest = new REST().setToken(c.token));
|
|
1383
|
+
this.moduleSuffix = moduleSuffix;
|
|
1371
1384
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1385
|
+
/**
|
|
1386
|
+
* Gets a command by name.
|
|
1387
|
+
*/
|
|
1374
1388
|
get(name) {
|
|
1375
|
-
|
|
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
|
+
}
|
|
1376
1405
|
}
|
|
1377
1406
|
/**
|
|
1378
|
-
*
|
|
1407
|
+
* Gets/filters commands and orders them alphabetically
|
|
1379
1408
|
*/
|
|
1380
|
-
getAll(options) {
|
|
1409
|
+
getAll(options = {}) {
|
|
1381
1410
|
const matchedCommands = /* @__PURE__ */ new Map();
|
|
1382
1411
|
const isDev = this.client.config.app.devMode;
|
|
1383
1412
|
for (const cmd of this.commands.values()) {
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
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));
|
|
1388
1416
|
if (!nameMatched) continue;
|
|
1389
1417
|
}
|
|
1390
|
-
if (options
|
|
1391
|
-
matchedCommands.set(
|
|
1418
|
+
if (options.ignoreDeploymentOptions) {
|
|
1419
|
+
matchedCommands.set(commandName, cmd);
|
|
1392
1420
|
continue;
|
|
1393
1421
|
}
|
|
1394
|
-
const deployment =
|
|
1422
|
+
const deployment = "deployment" in cmd.options ? cmd.options.deployment ?? {} : {};
|
|
1395
1423
|
const isProperEnv = !deployment.environments || deployment.environments.includes(isDev ? "development" : "production");
|
|
1396
1424
|
if (!isProperEnv) continue;
|
|
1397
|
-
if (options
|
|
1398
|
-
matchedCommands.set(
|
|
1425
|
+
if (options.globalOnly && deployment.global === false) continue;
|
|
1426
|
+
matchedCommands.set(commandName, cmd);
|
|
1399
1427
|
}
|
|
1400
|
-
return Array.from(matchedCommands.values()).sort((a, b) =>
|
|
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
|
+
});
|
|
1401
1433
|
}
|
|
1402
1434
|
/**
|
|
1403
|
-
* Groups commands by category alphabetically
|
|
1435
|
+
* Groups commands by category alphabetically.
|
|
1404
1436
|
*/
|
|
1405
1437
|
sortByCategory() {
|
|
1406
1438
|
const categories = /* @__PURE__ */ new Map();
|
|
@@ -1419,183 +1451,152 @@ var VimcordAppCommandManager = class {
|
|
|
1419
1451
|
entry.commands.push(cmd);
|
|
1420
1452
|
}
|
|
1421
1453
|
return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
|
|
1422
|
-
cat.commands.sort((a, b) =>
|
|
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
|
+
});
|
|
1423
1459
|
return cat;
|
|
1424
1460
|
});
|
|
1425
1461
|
}
|
|
1426
|
-
|
|
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)];
|
|
1523
|
+
}
|
|
1524
|
+
async registerGlobal(options = {}) {
|
|
1427
1525
|
const client = await this.client.whenReady();
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
}).values()
|
|
1434
|
-
).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);
|
|
1435
1531
|
if (!commands.length) {
|
|
1436
|
-
console.log(
|
|
1532
|
+
console.log("[CommandManager] No commands to register globally");
|
|
1437
1533
|
return;
|
|
1438
1534
|
}
|
|
1439
|
-
console.log(`[
|
|
1535
|
+
console.log(`[CommandManager] Registering (${commands.length}) commands globally...`);
|
|
1440
1536
|
try {
|
|
1441
|
-
await
|
|
1442
|
-
console.log(`[
|
|
1537
|
+
await client.rest.put(Routes.applicationCommands(client.user.id), { body: commands });
|
|
1538
|
+
console.log(`[CommandManager] \u2714 Registered app commands globally`);
|
|
1443
1539
|
} catch (err) {
|
|
1444
|
-
console.
|
|
1540
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands globally`, err);
|
|
1445
1541
|
}
|
|
1446
1542
|
}
|
|
1447
|
-
async
|
|
1543
|
+
async unregisterGlobal() {
|
|
1448
1544
|
const client = await this.client.whenReady();
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
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);
|
|
1455
1563
|
if (!commands.length) {
|
|
1456
|
-
console.log(
|
|
1564
|
+
console.log("[CommandManager] No commands to register by guild");
|
|
1457
1565
|
return;
|
|
1458
1566
|
}
|
|
1459
|
-
const guildIds = options
|
|
1460
|
-
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...`);
|
|
1461
1569
|
await Promise.all(
|
|
1462
1570
|
guildIds.map(
|
|
1463
|
-
(guildId) =>
|
|
1571
|
+
(guildId) => client.rest.put(Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
|
|
1464
1572
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
1465
|
-
console.log(`[
|
|
1573
|
+
console.log(`[CommandManager] \u2714 Set app commands in guild: ${guildId} (${gName})`);
|
|
1466
1574
|
}).catch((err) => {
|
|
1467
1575
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
1468
|
-
console.log(`[
|
|
1576
|
+
console.log(`[CommandManager] \u2716 Failed to set app commands in guild: ${guildId} (${gName})`, err);
|
|
1469
1577
|
})
|
|
1470
1578
|
)
|
|
1471
1579
|
);
|
|
1472
1580
|
}
|
|
1473
|
-
async unregisterGuild(options) {
|
|
1581
|
+
async unregisterGuild(options = {}) {
|
|
1474
1582
|
const client = await this.client.whenReady();
|
|
1475
|
-
|
|
1476
|
-
|
|
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...`);
|
|
1477
1589
|
await Promise.all(
|
|
1478
1590
|
guildIds.map(
|
|
1479
|
-
(guildId) =>
|
|
1480
|
-
(err) => console.log(`[${this.typeName}] \u2716 Failed to remove app commands in guild: ${guildId}`, err)
|
|
1481
|
-
)
|
|
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))
|
|
1482
1592
|
)
|
|
1483
1593
|
);
|
|
1484
1594
|
}
|
|
1485
|
-
async unregisterGlobal() {
|
|
1486
|
-
const client = await this.client.whenReady();
|
|
1487
|
-
try {
|
|
1488
|
-
await this.rest.put(Routes.applicationCommands(client.user.id), { body: [] });
|
|
1489
|
-
console.log(`[${this.typeName}] \u2714 Removed app commands globally`);
|
|
1490
|
-
} catch (err) {
|
|
1491
|
-
console.log(`[${this.typeName}] \u2716 Failed to remove app commands globally`, err);
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
};
|
|
1495
|
-
var VimcordSlashCommandManager = class extends VimcordAppCommandManager {
|
|
1496
|
-
constructor(client) {
|
|
1497
|
-
super(client, "SlashCommandManager");
|
|
1498
|
-
}
|
|
1499
|
-
async importFrom(dir, replaceAll = false) {
|
|
1500
|
-
if (replaceAll) this.commands.clear();
|
|
1501
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1502
|
-
const modules = (await Promise.all(
|
|
1503
|
-
dirs.map((d) => importModulesFromDir(d, "slash"))
|
|
1504
|
-
)).flat();
|
|
1505
|
-
for (const { module } of modules) {
|
|
1506
|
-
this.commands.set(module.default.builder.name, module.default);
|
|
1507
|
-
}
|
|
1508
|
-
this.client.logger.moduleLoaded("Slash Commands", modules.length);
|
|
1509
|
-
return this.commands;
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
var VimcordContextCommandManager = class extends VimcordAppCommandManager {
|
|
1513
|
-
constructor(client) {
|
|
1514
|
-
super(client, "ContextCommandManager");
|
|
1515
|
-
}
|
|
1516
|
-
async importFrom(dir, replaceAll = false) {
|
|
1517
|
-
if (replaceAll) this.commands.clear();
|
|
1518
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1519
|
-
const modules = (await Promise.all(
|
|
1520
|
-
dirs.map((d) => importModulesFromDir(d, "ctx"))
|
|
1521
|
-
)).flat();
|
|
1522
|
-
for (const { module } of modules) {
|
|
1523
|
-
this.commands.set(module.default.builder.name, module.default);
|
|
1524
|
-
}
|
|
1525
|
-
this.client.logger.moduleLoaded("Context Commands", modules.length);
|
|
1526
|
-
return this.commands;
|
|
1527
|
-
}
|
|
1528
|
-
};
|
|
1529
|
-
var VimcordPrefixCommandManager = class {
|
|
1530
|
-
constructor(client) {
|
|
1531
|
-
this.client = client;
|
|
1532
|
-
}
|
|
1533
|
-
commands = /* @__PURE__ */ new Map();
|
|
1534
|
-
resolve(trigger) {
|
|
1535
|
-
const config = this.client.config.prefixCommands;
|
|
1536
|
-
const search = config.allowCaseInsensitiveCommandNames ? trigger.toLowerCase() : trigger;
|
|
1537
|
-
return Array.from(this.commands.values()).find((cmd) => {
|
|
1538
|
-
const opts = cmd.toConfig();
|
|
1539
|
-
const name = config.allowCaseInsensitiveCommandNames ? opts.name.toLowerCase() : opts.name;
|
|
1540
|
-
if (name === search) return true;
|
|
1541
|
-
return opts.aliases?.some(
|
|
1542
|
-
(a) => config.allowCaseInsensitiveCommandNames ? a.toLowerCase() === search : a === search
|
|
1543
|
-
);
|
|
1544
|
-
});
|
|
1545
|
-
}
|
|
1546
|
-
/**
|
|
1547
|
-
* Groups commands by category alphabetically
|
|
1548
|
-
*/
|
|
1549
|
-
sortByCategory() {
|
|
1550
|
-
const categories = /* @__PURE__ */ new Map();
|
|
1551
|
-
for (const cmd of this.commands.values()) {
|
|
1552
|
-
const metadata = cmd.options.metadata;
|
|
1553
|
-
if (!metadata?.category) continue;
|
|
1554
|
-
let entry = categories.get(metadata.category);
|
|
1555
|
-
if (!entry) {
|
|
1556
|
-
entry = {
|
|
1557
|
-
name: metadata.category,
|
|
1558
|
-
emoji: metadata.categoryEmoji,
|
|
1559
|
-
commands: []
|
|
1560
|
-
};
|
|
1561
|
-
categories.set(metadata.category, entry);
|
|
1562
|
-
}
|
|
1563
|
-
entry.commands.push(cmd);
|
|
1564
|
-
}
|
|
1565
|
-
return Array.from(categories.values()).sort((a, b) => a.name.localeCompare(b.name)).map((cat) => {
|
|
1566
|
-
cat.commands.sort((a, b) => a.options.name.localeCompare(b.options.name));
|
|
1567
|
-
return cat;
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
async importFrom(dir, replaceAll = false) {
|
|
1571
|
-
if (replaceAll) this.commands.clear();
|
|
1572
|
-
const dirs = Array.isArray(dir) ? dir : [dir];
|
|
1573
|
-
const modules = (await Promise.all(
|
|
1574
|
-
dirs.map(
|
|
1575
|
-
(d) => importModulesFromDir(d, "prefix")
|
|
1576
|
-
)
|
|
1577
|
-
)).flat();
|
|
1578
|
-
for (const { module } of modules) {
|
|
1579
|
-
this.commands.set(module.default.toConfig().name, module.default);
|
|
1580
|
-
}
|
|
1581
|
-
this.client.logger.moduleLoaded("Prefix Commands", modules.length);
|
|
1582
|
-
return this.commands;
|
|
1583
|
-
}
|
|
1584
|
-
};
|
|
1585
|
-
var VimcordCommandManager = class {
|
|
1586
|
-
slash;
|
|
1587
|
-
prefix;
|
|
1588
|
-
context;
|
|
1589
|
-
constructor(client) {
|
|
1590
|
-
this.slash = new VimcordSlashCommandManager(client);
|
|
1591
|
-
this.prefix = new VimcordPrefixCommandManager(client);
|
|
1592
|
-
this.context = new VimcordContextCommandManager(client);
|
|
1593
|
-
}
|
|
1594
1595
|
};
|
|
1595
1596
|
|
|
1596
1597
|
// src/modules/event.manager.ts
|
|
1597
1598
|
import { Events } from "discord.js";
|
|
1598
|
-
var
|
|
1599
|
+
var EventManager = class {
|
|
1599
1600
|
client;
|
|
1600
1601
|
events = /* @__PURE__ */ new Map();
|
|
1601
1602
|
logger;
|
|
@@ -2178,7 +2179,7 @@ async function sendCommandErrorEmbed(client, error, guild, messageOrInteraction)
|
|
|
2178
2179
|
const embed_error = config?.embed?.(new BetterEmbed(), error, guild) || new BetterEmbed({
|
|
2179
2180
|
color: "Red",
|
|
2180
2181
|
title: "Something went wrong",
|
|
2181
|
-
description: "If you keep encountering this error, please report it"
|
|
2182
|
+
description: "If you keep encountering this error, please report it."
|
|
2182
2183
|
});
|
|
2183
2184
|
const msg = await embed_error.send(messageOrInteraction, {
|
|
2184
2185
|
components: [actionRow],
|
|
@@ -2224,7 +2225,7 @@ async function retryExponentialBackoff(fn, maxRetries = 3, retryDelay = 1e3) {
|
|
|
2224
2225
|
}
|
|
2225
2226
|
|
|
2226
2227
|
// package.json
|
|
2227
|
-
var version = "1.0.
|
|
2228
|
+
var version = "1.0.24";
|
|
2228
2229
|
|
|
2229
2230
|
// src/client.ts
|
|
2230
2231
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -2318,9 +2319,9 @@ var Vimcord = class _Vimcord extends Client2 {
|
|
|
2318
2319
|
prefixCommands: createVimcordPrefixCommandConfig(config.prefixCommands),
|
|
2319
2320
|
contextCommands: createVimcordContextCommandConfig(config.contextCommands)
|
|
2320
2321
|
};
|
|
2321
|
-
this.status = new
|
|
2322
|
-
this.events = new
|
|
2323
|
-
this.commands = new
|
|
2322
|
+
this.status = new StatusManager(this);
|
|
2323
|
+
this.events = new EventManager(this);
|
|
2324
|
+
this.commands = new CommandManager(this);
|
|
2324
2325
|
if (this.features.useEnv) {
|
|
2325
2326
|
if (typeof this.features.useEnv === "object") {
|
|
2326
2327
|
dotEnv.config({ quiet: true, ...this.features.useEnv });
|
|
@@ -2519,7 +2520,7 @@ var defaultPrefixCommandHandler = new EventBuilder({
|
|
|
2519
2520
|
const args = contentWithoutPrefix.split(/\s+/);
|
|
2520
2521
|
const trigger = args.shift();
|
|
2521
2522
|
if (!trigger) return;
|
|
2522
|
-
const command = client.commands.prefix.
|
|
2523
|
+
const command = client.commands.prefix.get(trigger);
|
|
2523
2524
|
if (!command) return;
|
|
2524
2525
|
message.content = args.join(" ");
|
|
2525
2526
|
try {
|
|
@@ -2839,7 +2840,7 @@ var MongoSchemaBuilder = class {
|
|
|
2839
2840
|
return this.model.findOne(filter, projection, { ...options, lean: options?.lean ?? true });
|
|
2840
2841
|
});
|
|
2841
2842
|
}
|
|
2842
|
-
async fetchAll(filter, projection, options) {
|
|
2843
|
+
async fetchAll(filter = {}, projection, options) {
|
|
2843
2844
|
return await this.execute(async () => {
|
|
2844
2845
|
return this.model.find(filter, projection, { ...options, lean: options?.lean ?? true });
|
|
2845
2846
|
}) || [];
|
|
@@ -4139,13 +4140,11 @@ CLI.addCommand("register", "Register app commands (slash & context) globally, or
|
|
|
4139
4140
|
switch (mode) {
|
|
4140
4141
|
case "guild":
|
|
4141
4142
|
CLI.logger.info("Registering guild commands...");
|
|
4142
|
-
await client.commands.
|
|
4143
|
-
await client.commands.context.registerGuild({ guilds: guildIds });
|
|
4143
|
+
await client.commands.registerGuild({ guilds: guildIds });
|
|
4144
4144
|
break;
|
|
4145
4145
|
case "global":
|
|
4146
4146
|
CLI.logger.info("Registering global commands...");
|
|
4147
|
-
await client.commands.
|
|
4148
|
-
await client.commands.context.registerGlobal();
|
|
4147
|
+
await client.commands.registerGlobal();
|
|
4149
4148
|
break;
|
|
4150
4149
|
}
|
|
4151
4150
|
});
|
|
@@ -4161,13 +4160,11 @@ CLI.addCommand("unregister", "Unregister app commands globally, or per guild", a
|
|
|
4161
4160
|
switch (mode) {
|
|
4162
4161
|
case "guild":
|
|
4163
4162
|
CLI.logger.info("Unregistering guild commands...");
|
|
4164
|
-
await client.commands.
|
|
4165
|
-
await client.commands.context.unregisterGuild({ guilds: guildIds });
|
|
4163
|
+
await client.commands.unregisterGuild({ guilds: guildIds });
|
|
4166
4164
|
break;
|
|
4167
4165
|
case "global":
|
|
4168
4166
|
CLI.logger.info("Unregistering global commands...");
|
|
4169
|
-
await client.commands.
|
|
4170
|
-
await client.commands.context.unregisterGlobal();
|
|
4167
|
+
await client.commands.unregisterGlobal();
|
|
4171
4168
|
break;
|
|
4172
4169
|
}
|
|
4173
4170
|
});
|
|
@@ -4268,16 +4265,20 @@ function pickRandom(arr, options) {
|
|
|
4268
4265
|
}
|
|
4269
4266
|
export {
|
|
4270
4267
|
BaseCommandBuilder,
|
|
4268
|
+
BaseCommandManager,
|
|
4271
4269
|
BetterCollector,
|
|
4272
4270
|
BetterContainer,
|
|
4273
4271
|
BetterEmbed,
|
|
4274
4272
|
BetterModal,
|
|
4275
4273
|
CLI,
|
|
4276
4274
|
CollectorTimeoutType,
|
|
4275
|
+
CommandManager,
|
|
4277
4276
|
CommandType,
|
|
4278
4277
|
ContextCommandBuilder,
|
|
4278
|
+
ContextCommandManager,
|
|
4279
4279
|
DynaSend,
|
|
4280
4280
|
EventBuilder,
|
|
4281
|
+
EventManager,
|
|
4281
4282
|
LOGGER_COLORS,
|
|
4282
4283
|
LogLevel,
|
|
4283
4284
|
Logger,
|
|
@@ -4288,20 +4289,17 @@ export {
|
|
|
4288
4289
|
PaginationType,
|
|
4289
4290
|
Paginator,
|
|
4290
4291
|
PrefixCommandBuilder,
|
|
4292
|
+
PrefixCommandManager,
|
|
4291
4293
|
Prompt,
|
|
4292
4294
|
PromptResolveType,
|
|
4293
4295
|
RateLimitScope,
|
|
4294
4296
|
SendMethod,
|
|
4295
4297
|
SlashCommandBuilder,
|
|
4298
|
+
SlashCommandManager,
|
|
4299
|
+
StatusManager,
|
|
4296
4300
|
StatusType,
|
|
4297
4301
|
Vimcord,
|
|
4298
4302
|
VimcordCLI,
|
|
4299
|
-
VimcordCommandManager,
|
|
4300
|
-
VimcordContextCommandManager,
|
|
4301
|
-
VimcordEventManager,
|
|
4302
|
-
VimcordPrefixCommandManager,
|
|
4303
|
-
VimcordSlashCommandManager,
|
|
4304
|
-
VimcordStatusManager,
|
|
4305
4303
|
__zero,
|
|
4306
4304
|
cleanMention,
|
|
4307
4305
|
clientInstances,
|