vimcord 1.0.51 → 1.0.53
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 +55 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +516 -520
- package/dist/index.d.ts +516 -520
- package/dist/index.js +55 -75
- 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.cjs
CHANGED
|
@@ -82,7 +82,6 @@ __export(index_exports, {
|
|
|
82
82
|
createMongoPlugin: () => createMongoPlugin,
|
|
83
83
|
createMongoSchema: () => createMongoSchema,
|
|
84
84
|
createPrefixCommandConfig: () => createPrefixCommandConfig,
|
|
85
|
-
createRandomId: () => createRandomId,
|
|
86
85
|
createSlashCommandConfig: () => createSlashCommandConfig,
|
|
87
86
|
createStaffConfig: () => createStaffConfig,
|
|
88
87
|
createToolsConfig: () => createToolsConfig,
|
|
@@ -317,7 +316,6 @@ var BaseCommandBuilder = class {
|
|
|
317
316
|
async run(client, ...args) {
|
|
318
317
|
const config = this.resolveConfig(client);
|
|
319
318
|
const ctx = this.extractContext(args);
|
|
320
|
-
let cancel = false;
|
|
321
319
|
try {
|
|
322
320
|
if (!config.enabled) {
|
|
323
321
|
return await config.onUsedWhenDisabled?.(...args);
|
|
@@ -332,16 +330,11 @@ var BaseCommandBuilder = class {
|
|
|
332
330
|
if (!await this.checkConditions(config, ...args)) {
|
|
333
331
|
return await config.onConditionsNotMet?.(...args);
|
|
334
332
|
}
|
|
335
|
-
await config.beforeExecute?.(
|
|
336
|
-
if (cancel) return;
|
|
333
|
+
await config.beforeExecute?.(...args);
|
|
337
334
|
if (config.logExecution !== false) {
|
|
338
|
-
const
|
|
339
|
-
const builderWithName = this;
|
|
340
|
-
const cmdName = optionsWithName.name ?? builderWithName.builder?.name ?? "Unknown";
|
|
335
|
+
const cmdName = this.options.name || this.builder?.name || "Unknown";
|
|
341
336
|
const location = ctx.guild ? `${ctx.guild.name} (${ctx.guild.id})` : "Direct Messages";
|
|
342
|
-
|
|
343
|
-
client.logger.commandExecuted(cmdName, ctx.user.username, location);
|
|
344
|
-
}
|
|
337
|
+
client.logger.commandExecuted(cmdName, ctx.user.username, location);
|
|
345
338
|
}
|
|
346
339
|
const result = await config.execute?.(...args);
|
|
347
340
|
await config.afterExecute?.(result, ...args);
|
|
@@ -569,7 +562,9 @@ var Logger = class {
|
|
|
569
562
|
extend(extras) {
|
|
570
563
|
for (const [key, fn] of Object.entries(extras)) {
|
|
571
564
|
if (typeof fn === "function") {
|
|
572
|
-
this[key] = (...args)
|
|
565
|
+
this[key] = function(...args) {
|
|
566
|
+
return fn.call(this, ...args);
|
|
567
|
+
};
|
|
573
568
|
}
|
|
574
569
|
}
|
|
575
570
|
return this;
|
|
@@ -939,14 +934,12 @@ var contextCommandHandler = new EventBuilder({
|
|
|
939
934
|
if (!command) {
|
|
940
935
|
const content = `**${interaction.commandName}** is not a registered context command.`;
|
|
941
936
|
if (interaction.replied || interaction.deferred) {
|
|
942
|
-
|
|
943
|
-
} else {
|
|
944
|
-
await interaction.reply({ content, flags: "Ephemeral" });
|
|
937
|
+
return interaction.followUp({ content, flags: "Ephemeral" });
|
|
945
938
|
}
|
|
946
|
-
return;
|
|
939
|
+
return interaction.reply({ content, flags: "Ephemeral" });
|
|
947
940
|
}
|
|
948
941
|
try {
|
|
949
|
-
await command.run(client, client, interaction);
|
|
942
|
+
return await command.run(client, client, interaction);
|
|
950
943
|
} catch (err) {
|
|
951
944
|
await client.error.handleCommandError(err, interaction.guild, interaction);
|
|
952
945
|
}
|
|
@@ -1005,14 +998,12 @@ var slashCommandHandler = new EventBuilder({
|
|
|
1005
998
|
if (!command) {
|
|
1006
999
|
const content = `**/\`${interaction.commandName}\`** is not a registered command.`;
|
|
1007
1000
|
if (interaction.replied || interaction.deferred) {
|
|
1008
|
-
|
|
1009
|
-
} else {
|
|
1010
|
-
await interaction.reply({ content, flags: "Ephemeral" });
|
|
1001
|
+
return interaction.followUp({ content, flags: "Ephemeral" });
|
|
1011
1002
|
}
|
|
1012
|
-
return;
|
|
1003
|
+
return interaction.reply({ content, flags: "Ephemeral" });
|
|
1013
1004
|
}
|
|
1014
1005
|
try {
|
|
1015
|
-
await command.run(client, client, interaction);
|
|
1006
|
+
return await command.run(client, client, interaction);
|
|
1016
1007
|
} catch (err) {
|
|
1017
1008
|
await client.error.handleCommandError(err, interaction.guild, interaction);
|
|
1018
1009
|
}
|
|
@@ -1796,7 +1787,7 @@ var VimcordErrorHandler = class {
|
|
|
1796
1787
|
var import_chalk2 = __toESM(require("chalk"));
|
|
1797
1788
|
|
|
1798
1789
|
// package.json
|
|
1799
|
-
var version = "1.0.
|
|
1790
|
+
var version = "1.0.53";
|
|
1800
1791
|
|
|
1801
1792
|
// src/client/vimcord.logger.ts
|
|
1802
1793
|
var clientLoggerFactory = (client) => new Logger({ prefixEmoji: "\u26A1", prefix: `vimcord (i${client.clientId})` }).extend({
|
|
@@ -1872,11 +1863,9 @@ function getDevMode() {
|
|
|
1872
1863
|
}
|
|
1873
1864
|
|
|
1874
1865
|
// src/configs/app.config.ts
|
|
1875
|
-
var packageJson = getPackageJson();
|
|
1876
|
-
var version2 = typeof packageJson.version === "string" ? packageJson.version : "1.0.0";
|
|
1877
1866
|
var defaultConfig = {
|
|
1878
1867
|
name: "Discord Bot",
|
|
1879
|
-
version:
|
|
1868
|
+
version: getPackageJson()?.version ?? "1.0.0",
|
|
1880
1869
|
devMode: getDevMode(),
|
|
1881
1870
|
verbose: false,
|
|
1882
1871
|
enableCLI: false,
|
|
@@ -2200,16 +2189,11 @@ var CommandManager = class {
|
|
|
2200
2189
|
slash;
|
|
2201
2190
|
prefix;
|
|
2202
2191
|
context;
|
|
2203
|
-
logger;
|
|
2204
2192
|
constructor(client) {
|
|
2205
2193
|
this.client = client;
|
|
2206
2194
|
this.slash = new SlashCommandManager(client);
|
|
2207
2195
|
this.prefix = new PrefixCommandManager(client);
|
|
2208
2196
|
this.context = new ContextCommandManager(client);
|
|
2209
|
-
this.logger = new Logger({
|
|
2210
|
-
prefixEmoji: "\u26A1",
|
|
2211
|
-
prefix: `vimcord (i${client.clientId}) [CommandManager]`
|
|
2212
|
-
});
|
|
2213
2197
|
}
|
|
2214
2198
|
getAllAppCommands(options = {}) {
|
|
2215
2199
|
return [...this.slash.getAll(options), ...this.context.getAll(options)];
|
|
@@ -2217,21 +2201,23 @@ var CommandManager = class {
|
|
|
2217
2201
|
async registerGlobal(options = {}) {
|
|
2218
2202
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2219
2203
|
if (!client.rest) {
|
|
2220
|
-
|
|
2204
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands globally: REST is not initialized`);
|
|
2221
2205
|
return;
|
|
2222
2206
|
}
|
|
2223
2207
|
const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
|
|
2224
2208
|
if (!commands.length) {
|
|
2225
|
-
|
|
2209
|
+
console.log("[CommandManager] No commands to register globally");
|
|
2226
2210
|
return;
|
|
2227
2211
|
}
|
|
2228
|
-
|
|
2212
|
+
console.log(
|
|
2213
|
+
`[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} globally...`
|
|
2214
|
+
);
|
|
2229
2215
|
try {
|
|
2230
2216
|
await client.rest.put(import_discord8.Routes.applicationCommands(client.user.id), { body: commands });
|
|
2231
|
-
|
|
2217
|
+
console.log(`[CommandManager] \u2714 Registered app ${commands.length === 1 ? "command" : "commands"} globally`);
|
|
2232
2218
|
} catch (err) {
|
|
2233
|
-
|
|
2234
|
-
`Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
|
|
2219
|
+
console.error(
|
|
2220
|
+
`[CommandManager] \u2716 Failed to register app ${commands.length === 1 ? "command" : "commands"} globally`,
|
|
2235
2221
|
err
|
|
2236
2222
|
);
|
|
2237
2223
|
}
|
|
@@ -2239,66 +2225,60 @@ var CommandManager = class {
|
|
|
2239
2225
|
async unregisterGlobal() {
|
|
2240
2226
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2241
2227
|
if (!client.rest) {
|
|
2242
|
-
|
|
2228
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally: REST is not initialized`);
|
|
2243
2229
|
return;
|
|
2244
2230
|
}
|
|
2245
2231
|
try {
|
|
2246
2232
|
await client.rest.put(import_discord8.Routes.applicationCommands(client.user.id), { body: [] });
|
|
2247
|
-
|
|
2233
|
+
console.log(`[CommandManager] \u2714 Removed app commands globally`);
|
|
2248
2234
|
} catch (err) {
|
|
2249
|
-
|
|
2235
|
+
console.error(`[CommandManager] \u2716 Failed to remove app commands globally`, err);
|
|
2250
2236
|
}
|
|
2251
2237
|
}
|
|
2252
2238
|
async registerGuild(options = {}) {
|
|
2253
2239
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2254
2240
|
if (!client.rest) {
|
|
2255
|
-
|
|
2241
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
2256
2242
|
return;
|
|
2257
2243
|
}
|
|
2258
2244
|
const commands = this.getAllAppCommands(options).map((cmd) => cmd.builder.toJSON());
|
|
2259
2245
|
if (!commands.length) {
|
|
2260
|
-
|
|
2246
|
+
console.log("[CommandManager] No commands to register by guild");
|
|
2261
2247
|
return;
|
|
2262
2248
|
}
|
|
2263
2249
|
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
2264
|
-
|
|
2265
|
-
`Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
|
|
2250
|
+
console.log(
|
|
2251
|
+
`[CommandManager] Registering (${commands.length}) ${commands.length === 1 ? "command" : "commands"} for ${guildIds.length} guilds...`
|
|
2266
2252
|
);
|
|
2267
2253
|
await Promise.all(
|
|
2268
|
-
guildIds.map(
|
|
2269
|
-
|
|
2270
|
-
await client.rest.put(import_discord8.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands });
|
|
2254
|
+
guildIds.map(
|
|
2255
|
+
(guildId) => client.rest.put(import_discord8.Routes.applicationGuildCommands(client.user.id, guildId), { body: commands }).then(() => {
|
|
2271
2256
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
2272
|
-
|
|
2273
|
-
`Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
|
|
2257
|
+
console.log(
|
|
2258
|
+
`[CommandManager] \u2714 Set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`
|
|
2274
2259
|
);
|
|
2275
|
-
}
|
|
2260
|
+
}).catch((err) => {
|
|
2276
2261
|
const gName = client.guilds.cache.get(guildId)?.name || "n/a";
|
|
2277
|
-
|
|
2278
|
-
`Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
|
|
2262
|
+
console.log(
|
|
2263
|
+
`[CommandManager] \u2716 Failed to set app ${commands.length === 1 ? "command" : "commands"} in guild: ${guildId} (${gName})`,
|
|
2279
2264
|
err
|
|
2280
2265
|
);
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2266
|
+
})
|
|
2267
|
+
)
|
|
2283
2268
|
);
|
|
2284
2269
|
}
|
|
2285
2270
|
async unregisterGuild(options = {}) {
|
|
2286
2271
|
const client = await Vimcord.getReadyInstance(this.client.clientId);
|
|
2287
2272
|
if (!client.rest) {
|
|
2288
|
-
|
|
2273
|
+
console.error(`[CommandManager] \u2716 Failed to register app commands by guild: REST is not initialized`);
|
|
2289
2274
|
return;
|
|
2290
2275
|
}
|
|
2291
2276
|
const guildIds = options.guilds || client.guilds.cache.map((g) => g.id);
|
|
2292
|
-
|
|
2277
|
+
console.log(`[CommandManager] Unregistering commands from ${guildIds.length} guilds...`);
|
|
2293
2278
|
await Promise.all(
|
|
2294
|
-
guildIds.map(
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
this.logger.success(`Removed app commands in guild: ${guildId}`);
|
|
2298
|
-
} catch (err) {
|
|
2299
|
-
this.logger.error(`Failed to remove app commands in guild: ${guildId}`, err);
|
|
2300
|
-
}
|
|
2301
|
-
})
|
|
2279
|
+
guildIds.map(
|
|
2280
|
+
(guildId) => client.rest.put(import_discord8.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))
|
|
2281
|
+
)
|
|
2302
2282
|
);
|
|
2303
2283
|
}
|
|
2304
2284
|
};
|
|
@@ -2806,8 +2786,8 @@ var Vimcord = class _Vimcord extends import_discord11.Client {
|
|
|
2806
2786
|
return this.config.app.version;
|
|
2807
2787
|
}
|
|
2808
2788
|
// prettier-ignore
|
|
2809
|
-
set $version(
|
|
2810
|
-
this.config.app.version =
|
|
2789
|
+
set $version(version2) {
|
|
2790
|
+
this.config.app.version = version2;
|
|
2811
2791
|
}
|
|
2812
2792
|
/** Current dev mode state */
|
|
2813
2793
|
// prettier-ignore
|
|
@@ -4055,7 +4035,7 @@ var Paginator = class {
|
|
|
4055
4035
|
if (disabledNavRow.components.length > 0) {
|
|
4056
4036
|
newComponents.push(disabledNavRow);
|
|
4057
4037
|
}
|
|
4058
|
-
await this.data.message.edit({ components: newComponents });
|
|
4038
|
+
await this.data.message.edit({ components: newComponents }).catch(Boolean);
|
|
4059
4039
|
if (this.options.useReactions) {
|
|
4060
4040
|
await this.nav_removeFromMessage();
|
|
4061
4041
|
}
|
|
@@ -4066,7 +4046,7 @@ var Paginator = class {
|
|
|
4066
4046
|
}
|
|
4067
4047
|
break;
|
|
4068
4048
|
case 2 /* DeleteMessage */:
|
|
4069
|
-
await this.data.message.delete();
|
|
4049
|
+
await this.data.message.delete().catch(Boolean);
|
|
4070
4050
|
break;
|
|
4071
4051
|
case 3 /* DoNothing */:
|
|
4072
4052
|
break;
|
|
@@ -4076,16 +4056,16 @@ var Paginator = class {
|
|
|
4076
4056
|
async nav_removeFromMessage() {
|
|
4077
4057
|
if (!this.data.message?.editable) return;
|
|
4078
4058
|
if (this.options.useReactions) {
|
|
4079
|
-
await this.data.message.reactions.removeAll();
|
|
4059
|
+
await this.data.message.reactions.removeAll().catch(Boolean);
|
|
4080
4060
|
} else {
|
|
4081
4061
|
const newComponents = this.data.message.components.filter((c) => c.type !== import_discord14.ComponentType.Container);
|
|
4082
|
-
await this.data.message.edit({ components: newComponents });
|
|
4062
|
+
await this.data.message.edit({ components: newComponents }).catch(Boolean);
|
|
4083
4063
|
}
|
|
4084
4064
|
}
|
|
4085
4065
|
async nav_addReactions() {
|
|
4086
4066
|
if (!this.data.message || !this.options.useReactions || !this.data.navigation.reactions.length) return;
|
|
4087
4067
|
for (const r of this.data.navigation.reactions) {
|
|
4088
|
-
await this.data.message.react(r.id);
|
|
4068
|
+
await this.data.message.react(r.id).catch(Boolean);
|
|
4089
4069
|
}
|
|
4090
4070
|
}
|
|
4091
4071
|
async collect_components() {
|
|
@@ -4120,7 +4100,7 @@ var Paginator = class {
|
|
|
4120
4100
|
}
|
|
4121
4101
|
switch (i.customId) {
|
|
4122
4102
|
case "ssm_chapterSelect":
|
|
4123
|
-
await i.deferUpdate();
|
|
4103
|
+
await i.deferUpdate().catch(Boolean);
|
|
4124
4104
|
const chapterIndex = this.chapters.findIndex(
|
|
4125
4105
|
(c) => c.id === i.values[0]
|
|
4126
4106
|
);
|
|
@@ -4128,25 +4108,25 @@ var Paginator = class {
|
|
|
4128
4108
|
await this.refresh();
|
|
4129
4109
|
break;
|
|
4130
4110
|
case "btn_first":
|
|
4131
|
-
await i.deferUpdate();
|
|
4111
|
+
await i.deferUpdate().catch(Boolean);
|
|
4132
4112
|
this.callEventStack("first", this.data.page.current, this.data.page.index);
|
|
4133
4113
|
await this.setPage(this.data.page.index.chapter, 0);
|
|
4134
4114
|
await this.refresh();
|
|
4135
4115
|
break;
|
|
4136
4116
|
case "btn_back":
|
|
4137
|
-
await i.deferUpdate();
|
|
4117
|
+
await i.deferUpdate().catch(Boolean);
|
|
4138
4118
|
this.callEventStack("back", this.data.page.current, this.data.page.index);
|
|
4139
4119
|
await this.setPage(this.data.page.index.chapter, this.data.page.index.nested - 1);
|
|
4140
4120
|
await this.refresh();
|
|
4141
4121
|
break;
|
|
4142
4122
|
case "btn_next":
|
|
4143
|
-
await i.deferUpdate();
|
|
4123
|
+
await i.deferUpdate().catch(Boolean);
|
|
4144
4124
|
this.callEventStack("next", this.data.page.current, this.data.page.index);
|
|
4145
4125
|
await this.setPage(this.data.page.index.chapter, this.data.page.index.nested + 1);
|
|
4146
4126
|
await this.refresh();
|
|
4147
4127
|
break;
|
|
4148
4128
|
case "btn_last":
|
|
4149
|
-
await i.deferUpdate();
|
|
4129
|
+
await i.deferUpdate().catch(Boolean);
|
|
4150
4130
|
this.callEventStack("last", this.data.page.current, this.data.page.index);
|
|
4151
4131
|
await this.setPage(
|
|
4152
4132
|
this.data.page.index.chapter,
|
|
@@ -4544,7 +4524,6 @@ async function prompt(handler, options, sendOptions) {
|
|
|
4544
4524
|
createMongoPlugin,
|
|
4545
4525
|
createMongoSchema,
|
|
4546
4526
|
createPrefixCommandConfig,
|
|
4547
|
-
createRandomId,
|
|
4548
4527
|
createSlashCommandConfig,
|
|
4549
4528
|
createStaffConfig,
|
|
4550
4529
|
createToolsConfig,
|